0
$\begingroup$

I have a view direction in 3d space described with 2 values: Horizontal and Vertical (x and y) ranging the full 360 degrees (from -180 to +180), thus describing every possible view direction.

It seems fairly straight forward to me, that the angle between (0,0) and (5,0) would be 5 degrees.

But what is the angle between (0,0) and (5,5). If it was 2 points in 2d I would use Pythagoras theorem; having the difference be sqrt(5^2 + 5^2). But I don't think that would apply in 3d? How do I go about calculating the angle between these 2 directions?

This has likely been asked before, but I probably don't know the correct wording. I assume the "view directions" should be calculated as vectors, but I'm not sure how.

Thanks

$\endgroup$
  • $\begingroup$ It's not clear how $x$ and $y$ define a direction in the first place. Can you give more details about your intended representation? It is more common to describe directions in 3D using a 3D unit vector, i.e. three coordinates $x$, $y$, and $z$ such that $x^2+y^2+z^2=1$. $\endgroup$ – Rahul Oct 3 '18 at 8:19
  • $\begingroup$ Also, how would Pythagoras (in 2d) give you an angle? $\endgroup$ – Jaap Scherphuis Oct 3 '18 at 8:44
  • $\begingroup$ Maybe look at the wiki page for great-circle distance. $\endgroup$ – Jaap Scherphuis Oct 3 '18 at 8:48
  • $\begingroup$ @Rahul Imagine a fixed point of reference being (0,0) - 0 degrees horizontal, 0 degrees vertical. Now, if the point of view turns 5 degrees "right" along the horizontal axis, this could now be described as (5,0). When we then turn the point of view further "up" along the vertical axis, this would now be (5,5). My question is: What is the angle between (0,0) and (5,5)? $\endgroup$ – Scherling Oct 3 '18 at 10:54
  • $\begingroup$ First, one thing you have to be careful about is that the way you describe it, the order of rotation matters: turning "right" 5 degrees and then "up" 5 degrees is different from turning "up" 5 degrees and then "right" 5 degrees. This is hard to visualize, but easier if you think about what happens when rotating 90 degrees each time. If you are clear that this situation is what you want, and which rotation should be done first, then you can apply Hugo's formula. $\endgroup$ – Rahul Oct 3 '18 at 11:14
1
$\begingroup$

If I understood well, by a "direction" ($\phi, \theta)$ (I assume the angles between $0$ and $2 \pi$) you mean the unit vector $u(\phi, \theta) = (\cos \theta \cos \phi, \cos \theta \sin \phi, \sin \theta)$. The angle $\alpha$ between $u(\theta, \phi)$ and $u(\theta', \phi')$ may be calculated by taking the scalar product $u(\theta, \phi) \cdot u(\theta', \phi')$ as follows: $$ \cos \alpha = \cos \theta \cos \theta' (\cos \phi \cos \phi' + \sin \phi \sin \phi') + \sin \theta \sin \theta' = \cos \theta \cos \theta' \cos (\phi-\phi') + \sin \theta \sin \theta', $$ hence $$ \alpha = \cos^{-1} (\cos \theta \cos \theta' \cos (\phi-\phi') + \sin \theta \sin \theta') $$

$\endgroup$
  • $\begingroup$ I'm probably talking about a unit vector - I'm just too inexperienced with vectors to fully understand how my 2 "view directions", a.k.a 360 degrees horizontal and vertical values translates to a vector. I could also explain my question as: If I point one arm straigt in front of me, and then, using my first arm as reference, point the other arm exactly 5 degrees right on the horizontal axis, and 5 degrees up on the vertical axis, what is the angle between my 2 arms? $\endgroup$ – Scherling Oct 3 '18 at 11:03
  • $\begingroup$ The best way is to see all this on a globe. In my computations, $\phi$ is the longitude, between 0 (Greenwich) and $2\pi$ (Greenwich again), and $\theta$ is the latitude, between $-\pi$ (South pole) and $+\pi$ (North pole). Hope it's clearer now. $\endgroup$ – Hugo Oct 3 '18 at 12:20
  • $\begingroup$ About your "arm" example, as already explained in the comments to your questions, it different if you first rotate right and then up, or first up and then right. Think about the globe, trust me! :) $\endgroup$ – Hugo Oct 3 '18 at 12:22
  • $\begingroup$ But that's the thing, I AM thinking about a globe, and specifically lattitude and longitude. You'll end on the same spot no matter which one you mention first, as they both have their own individual fixed reference "circles" along the edge of earth. In my example, I have a horizontal 0 "Equator" and vertical 0 "Prime median" (To use the globe example). Starting at perfect (0,0) I move 5 degrees along each circle. I now point to the center of the globe, while my friend standing at 0.0 start position does the same. What is the angle at which the 2 imaginary lines meet at the center? $\endgroup$ – Scherling Oct 4 '18 at 11:59
  • $\begingroup$ The angle is the une given by my formula, where $\theta$ is the latitude and $\phi$ the longitude. $\endgroup$ – Hugo Oct 4 '18 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.