Angle of a line?

Razor89

Member
Joined
Dec 15, 2004
Messages
12
If I have two coordinates for a line, the begining and the end,
how do I find what angle the line is pointing relative to the begining of the
line?

I need this for a upcoming project where I need to move the camera in
a 2D world and it has to follow a line thus I need to know the angle which
the camera needs to move at.

Thanks!
 
Razor89 said:
If I have two coordinates for a line, the begining and the end,
how do I find what angle the line is pointing relative to the begining of the
line?

I need this for a upcoming project where I need to move the camera in
a 2D world and it has to follow a line thus I need to know the angle which
the camera needs to move at.

Thanks!
tan θ = (Y2-Y1) / (X2-X1)
θ = arctan((Y2-Y1) / (X2-X1))
 
I think I might be able to work with that weird looking
formula but do you have any code by any chance?
 
Dim lineAngle as Single = tan(arc((Y2-Y1) / (X2-X1)))

or

Dim lineAngle as Single = Math.Atan((Y2-Y1) / (X2-X1))

Is that correct?
 
Ok, thanks, Im not good with math and I havent made my way to algebra
yet so please bare with me :)
 
Back
Top