Skip to main content
Mathematics

Return to Revisions

2 of 2
replaced http://stackoverflow.com/ with https://stackoverflow.com/

See https://stackoverflow.com/a/21486462/380384

Or follow these steps

  1. Create two vectors $A=(S-E)$ and $B=(W-E)$
  2. Calculate the dot product $$\cos\theta = A\cdot B = A_x B_x + A_z B_z$$
  3. Calculate the magnitude of the cross product $$\sin\theta = |A \times B| = A_x B_y - A_y B_x $$
  4. Use the ATAN2() function to get the included angle $$\theta = {\rm atan2}(\sin \theta, \cos \theta)$$
  5. Get the desired angle by $\pi - \theta$
John Alexiou
  • 14.8k
  • 1
  • 41
  • 78

AltStyle によって変換されたページ (->オリジナル) /