C#C
C#4y ago
changffof

crankshaft rotation

I am making a program that dictates the position of the piston in millimeters with respect to the degrees of rotation of the crankshaft, the idea is that both variables, reach 0, according to the parameters that the user has set, ie the degrees of rotation to accompany the level of descent of the piston that this is in millimeters. example
90 degrees = 30mm, 89 degrees=28mm,
88 degrees =27.5mm, and so on, until both reach 0, for each degree of crankshaft rotation there are certain millimeters traveled, I would need to do some for loop, or something like that, if anyone knows help, pd: I do not know much about programming, I attach an image to what I mean

this is the code:

public double ConvertToRadians(double angle)
{
return angle * Math.PI / 180;
}

public double ConvertToDegree(double rad)
{
return rad * 180 / Math.PI;
}




public void calc_Click(object sender, EventArgs e)
{


double crank_angle;
double st, conrod, x, ct, alpha;
st = double.Parse(textBox65.Text);
conrod = double.Parse(textBox1.Text);
crank_angle = double.Parse(textBox2.Text);



ct = st / 2;
alpha = ConvertToDegree(Math.Asin(ct * Math.Sin(ConvertToRadians(crank_angle)) / conrod));
x = conrod + ct - Math.Cos(ConvertToRadians(alpha)) * conrod - Math.Cos(ConvertToRadians(crank_angle)) * ct;

textBox3.Text = string.Format("{0:N3}", x);




}
2d1229755303de1ef59bd2885a11619f.png
26782cc138094a7c0ebd5596ef3a54ed.png
5e5bc2a187c00a244c8529f5fe75f4bc.png
Was this page helpful?