I am searching for an alternative method for solving for the angle between two vectors to verify my current solutions. the method I have currently used is the dot product, wondering if anyone knows?
Angle between two three-dimensional vectors
5.3k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail AtThere are 3 best solutions below
On
The dot product works very well when the angle is close to a right angle. The reason this is so is related to the fact that for two such angles the difference in their cosines is nearly proportional to the angle between them.
As the angle approaches zero, the cosine of the angle approaches $1$ much more quickly. For small enough angles (but still large enough to be considered distinct from zero for many purposes), the cosine is so close to $1$ that you may not have enough digits in your calculator or computer data type to tell the difference. So you will not be able to measure such angles at all.
The cross product works very well when the angle is nearly zero. The reason is related to the fact that the sine of such an angle is nearly proportional to the angle. For angles near a right angle, however, the cross product runs into a difficulty similar to the dot product. It performs very poorly on the task of distinguishing those angles. It also fails to distinguish between an angle of $0.01$ radians and an angle of $\pi - 0.01$ radians (or between $1$ degree and $179$ degrees, for another example).
A more universally reliable method is to take the dot product and the cross product. Then you have both the sine and the cosine of the angle.
You can use those values and an arc tangent function
(in a software program, preferably the two-parameter atan2 function)
to find the angle.
Another way to get the angle between vectors $u$ and $v$ is:
- Project $v$ perpendicularly onto $u$ with the help of the dot product $u\cdot v$; call the resulting vector $v_\|.$
- Let $v_\perp = v - v_\|,$ which is a vector perpendicular to $u$ in the same plane as $u$ and $v.$
- If $\|v_\perp\| = 0,$ recall the dot product of $u\cdot v$ that you computed in the first step; if $u\cdot v > 0$ the angle is zero; otherwise the angle is $\pi.$
- If $\|v_\perp\| > 0,$ let $v_1 = \frac{\|u\|}{\|v_\perp\|} v_\perp,$ that is, find a vector the same magnitude as $u$ in the $v_\perp$ direction.
- Then $\|u\| \|v\| \cos \theta = v \cdot u$ (which you already computed in the first step) and $\|u\| \|v\| \sin \theta = v \cdot v_1,$ where $\theta$ is the angle between $u$ and $v.$
- Use $\|u\| \|v\| \sin\theta$ and $\|u\| \|v\| \cos\theta$ as parameters to
atan2to find $\theta.$
On
This approach also works in higher dimensional spaces.
Use the following:
Herons Formula
Law of sines
Normalize the two vectors $\vec a$ and $\vec b$.
Calculate the lengths, $a(=1)$, $b(=1)$ and $c$ of the three vectors $\vec a$, $\vec b$, and $\vec c = \vec b - \vec a$.
Calculate the area $T$ formed by these three vectors.
Setup the equation $sin(\gamma) = K$ and solve for $0 \lt \gamma \le \pi/2$ using arcsin.
If $c^2 \gt 2$, reset $\gamma$ to $\pi - \gamma$.
The angle between $\vec a$ and $\vec b$ is $\gamma$.
Another answer discussed problems that will occur calculating the arcsin of $1$. If the occurs then calculate one of the other angles of our isosceles triangle in order to get $\gamma$.
You can use the cross product. $|\vec a \times \vec b|=ab\sin\theta$, where $\theta$ is the angle between the two vectors