0
$\begingroup$

How do I find the following angle $a$ given $2$ points $(x, y, z)$ in $3$-dimensional space?

I've drawn $2$ points, one in green, one in red. The curved black line being the earth, and the normal vector is perpendicular to the earth. Green point is on the ground, and red point will always be above ground. Can assume earth is centered at $(0, 0, 0)$

Diagram

Edit: can assume red vector is pointing in opposite direction than drawn.

$\endgroup$

2 Answers 2

1
$\begingroup$

Let $\vec{p}_r = (x_r, y_r, z_r)$ be the red point, and $\vec{p}_g = (x_g, y_g, z_g)$ be the green point. The direction unit vectors are then $$\hat{r} = \frac{\vec{p}_r - \vec{p}_g}{\left\lVert \vec{p}_r - \vec{p}_g \right\rVert}, \quad \hat{g} = \frac{\vec{p}_g}{\left\lVert \vec{p}_g \right\rVert}$$ where $\lVert\vec{p}\rVert = \sqrt{\vec{p} \cdot \vec{p}} = \sqrt{x^2 + y^2 + z^2}$.

The angle $\theta$ between the two unit vectors fulfills $$\begin{aligned} \cos\theta &= \hat{r} \cdot \hat{g} \\ \sin\theta &= \left\lVert \hat{r} \times \hat{g} \right\rVert \\ \end{aligned}$$ and usually you use $\theta = \arccos(\hat{r} \cdot \hat{g})$.

$\endgroup$
0
1
$\begingroup$

The angle between two vectors can be given by the dot product. More specifically, if $a$ and $b$ are vectors, then $$a\cdot b = \|a\|\|b\|\cos\theta,$$ where $\|a\|$ is the length of $a$, $\|b\|$ is the length of $b$, and $\theta$ is the angle between the two (in radians!). So here you have $a= (1,1,1)$, $b =(1,1,1.3)$, then you can compute their lengths and solve for $\theta$.

$\endgroup$
2
  • $\begingroup$ rather than $(1,1,1.3)$, don't we need the vector formed between the points $(1,1,1.3)$ and $(1,1,1)$? $\endgroup$ Feb 25, 2021 at 0:40
  • 1
    $\begingroup$ Sorry, I misread your diagram. Yes, in that case, you would have $a = (1,1,1)$ and $b = (1,1,1.3) - (1,1,1)$. $\endgroup$
    – Phil
    Feb 25, 2021 at 1:33

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.