Math drawing question

P

Peter Proost

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
 
A

Andrew Morton

Peter said:
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.
 
P

Peter Proost

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
 
P

Peter Proost

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
 
A

Andrew Morton

Peter said:
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
 
P

Peter Proost

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

Thanks again for your answer, I'll give it a try later on. Just got out
of a meeting, and got a new one coming in 5 minutes.

Thanks,

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top