View Single Post
  #7   Spotlight this post!  
Unread 27-10-2013, 10:06
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,028
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Geometry & Trig Quiz

Quote:
Originally Posted by Aaron.Graeve View Post
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.


Reply With Quote