Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get angle of a line from horizon

I want to know how to get an angle of a line A-B from horizontal axis X. Other questions in SO do that only between two lines. I'm aware I can always draw second line A-C and calculate but I'm wondering if there's a faster method.

EDIT: I'm very sure I'm not doing a premature optimization.

like image 830
VOX Avatar asked Jun 30 '10 22:06

VOX


People also ask

How do you find the horizon angle?

Angle = ArcCos(R / R+h). for heights h in feet. The result will typically be good to 0.01 degree (except at the extremes of 25,000 and 41,000 feet, where it's off almost 0.02 degrees). E.g., with h = 33,293 feet, the angle should be around 1.5924 + 0.048892 * (33.293) = 3.22 degrees.

What is the number of degrees between a horizontal and a line?

@akashg: 90 - angleInDegrees ?


1 Answers

You can use atan for that.

angle = atan((By-Ay)/(Bx-Ax))
like image 89
Bart van Heukelom Avatar answered Oct 26 '22 22:10

Bart van Heukelom