Quote:
Originally Posted by Aaron.Graeve
The simple alternative to atan(dy/dx) wouldn't happen to be atan2(dy, dx), would it?
|
Yes it would. atan and atan2 have different behaviors.
atan's range is limited to -90 < atan < +90. So if the problem involves an angle like 95.7 degrees (as in the previously posted example), atan cannot return that value.
atan2's range is -180 <= atan2 <= +180 and it handles the quadrantal angles without crashing. Also, in many implementations (Octave is an example) atan2 handles the arguments (0,0) and returns 0.
You
can wrap conditional logic around atan in your own code to produce your own version of atan2, but it's better to use the library version if it's available. Pages 152 thru 158 of P J Plauger's classic 1992 book
The Standard C Library shows a reference implementation of atan and atan2.
I don't think you re-invented the wheel. Your diagram and accompanying explanation stated the simplifying assumptions explicitly, used a consistent reference coordinate system, and were very clear and easy to understand.