From: Peter Proost on 28 Apr 2010 03:14 Hi group, I have got a math/drawing question and as the question will show my math knowledge is of toddler level... I've got a line going from x1,y1 to x2,y2 then the user inputs an angle and a length for a second line starting from x2,y2 going to x3,y3 But how do I calculate the value for x3,y3? I think I need to do something with cosinus and sinus and my angle and length but I don't know what. Thanks in advance, Greetz, Peter
From: Andrew Morton on 28 Apr 2010 04:28 Peter Proost wrote: > I've got a line going from x1,y1 to x2,y2 then the user inputs an > angle and a length for a second line starting from x2,y2 going to > x3,y3 But how do I calculate the value for x3,y3? I think I need to do > something with cosinus and sinus and my angle and length but I don't > know what. x3=x2+r*cos(t) y3=y2+r*sin(t) where r is the length (commonly referred to as the radius in this situation) and t is the angle in radians (theta, angles are usually called theta for these things). (angle in radians)=(angle in degrees)*pi/180 And don't forget that the screen y-axis is upside-down compared to what you'd draw with pencil and paper. -- Andrew
From: Peter Proost on 28 Apr 2010 04:40 On 28/04/2010 10:28, Andrew Morton wrote: > Peter Proost wrote: >> I've got a line going from x1,y1 to x2,y2 then the user inputs an >> angle and a length for a second line starting from x2,y2 going to >> x3,y3 But how do I calculate the value for x3,y3? I think I need to do >> something with cosinus and sinus and my angle and length but I don't >> know what. > > x3=x2+r*cos(t) > y3=y2+r*sin(t) > > where r is the length (commonly referred to as the radius in this situation) > and t is the angle in radians (theta, angles are usually called theta for > these things). > > (angle in radians)=(angle in degrees)*pi/180 > > And don't forget that the screen y-axis is upside-down compared to what > you'd draw with pencil and paper. > Thanks a lot exactly what I needed. I was already aware of the .net y axis being upside-down Thanks again
From: Peter Proost on 28 Apr 2010 05:04 Hi, I've got an extra question which I forgot to mention in my original post. Thanks to your answer I can calculate x3,y3, but they need to be calculated with respect to the angle of the x1,y1 - x2,y2 line. I hope you get what I mean. Thanks again, Peter
From: Andrew Morton on 28 Apr 2010 05:44 Peter Proost wrote: > I've got an extra question which I forgot to mention in my original > post. Thanks to your answer I can calculate x3,y3, but they need to be > calculated with respect to the angle of the x1,y1 - x2,y2 line. I hope > you get what I mean. Angle of line (p1,p2) in radians=atan2(y2-y1, x2-x1) where p1=(x1,y1) and p2=(x2,y2). I recommend that you keep all angles in the code in radians, and only do the degrees<->radians conversions at the user-interface level. HTH -- Andrew
|
Next
|
Last
Pages: 1 2 Prev: Can't evaluate expressionin IDE debug mode Next: Is it possible with Linq to update a dataset? |