I've written a python code that calculates the dot product of two x,y,z points converted from lan/lon points (out of three lat/lon points)
My questions are this: I got this calculation from another source, It doesn't consider my third point at all, why is this, it doesn't need it?
how can I verify that my answer is true?
My answer Is 0.0017907536175649065 It doesn't match the angle it should on the map.
I mean, are the zeroes can be ignored? , It's just the answer I got doesn't make any sense to me.
My code if someone's instersted.
def get_angle():
bax = 3986139.124316147
bay = 3924600.2399883396
baz = 1126
acx = 3995519.3498883517
acy = 3919784.087359532
acz = 1800 - baz
a = [bax, bay, baz]
b = [acx, acy, acz]
a_mag = np.linalg.norm(a)
b_mag = np.linalg.norm(b)
theta = np.arccos(np.dot(a, b) / (a_mag * b_mag))
print(theta)
Your formula defines two new vectors, $\mathbf a$ and $\mathbf b$ in terms of three old vectors, $\mathbf B$, $\mathbf A$ and $\mathbf c$, which is absolutely perplexing naming. I think it's much clearer to just scrap all that and think about it as follows:
We have three points $A$, $B$, and $C$ (with position vectors $\mathbf a$, $\mathbf b$, $\mathbf c$, respectively). We wish to find the angle $\angle \mathit{ABC}$. We will do so by finding the angle between the two vectors $\overrightarrow{\mathit{BA}}$ and $\overrightarrow{\mathit{BC}}$. (Hopefully it is clear to you why this it the same thing).
But we can calculate $\overrightarrow{\mathit{BA}}$ and $\overrightarrow{\mathit{BC}}$ as $\mathbf a - \mathbf b$ and $\mathbf c - \mathbf b$ respectively. Then we can use the dot-product angle fact (in fact this is how some people define angle!):
The angle $\theta$ between two vectors $\mathbf u$, $\mathbf v$ (in $n$ dimensions) is given by \begin{equation*} \cos \theta = \frac{\mathbf u \cdot \mathbf v} {\lVert \mathbf u \rVert \lVert \mathbf v \rVert} \end{equation*}
This might culminate in a little program like so: