How can I turn the dot product of two normalized vectors into a percentage? When my vectors are perpendicular (90 degrees off) the dot product is 0, and when they are parallel (0 degrees off) the dot product is 1, but half way between these two states (45 degrees off) the dot product is around 0.7.
I'd like to manipulate the dot product to get a new value that represents "percentage aligned", so in the case above, half way between perpendicular and parallel, I would get the value 0.5, and the value would proceed in a linear fashion as you approach 0 or 1.
Thanks!
 A: If these are unit vectors, their dot product is the cosine of the angle between them.
In your examples, $\cos 0^{\circ}=1$, $\cos 90^{\circ}=0$, and $\cos 60^{\circ}=0.5$.
The angle $\theta$ producing the number $t\in[0,1]$ is $\theta = \cos^{-1} t$. That’s the arccosine or inverse cosine. It’s defined by $\cos \theta =t$.
And observe that $\cos 45^{\circ}=1/\sqrt{2}\approx0.7071$.
A: Observe that $\frac{a \cdot b}{|a||b|}=\cos{\theta}$ is the geometric definition of a dot product. Therefore $\theta = \arccos{\frac{a \cdot b}{|a||b|}}$ is the angle between the two vectors. A percentage is just a portion of a total yes? Here your total is $90^\circ$
I would then think that $\dfrac{\theta}{90^\circ}$ is your "percentage aligned". Let's test it.
Take 2 vectors at a $45^\circ$ angle say, $a = (0,1)$ and $b = (1,1)$ then
$\frac{a \cdot b}{|a||b|} = \frac{(0,1) \cdot (1,1)}{1\cdot\sqrt{2}} = \frac{1}{\sqrt{2}}
$
So $\theta = \arccos{\frac{1}{\sqrt{2}}} = 45^\circ$ and therefore $\frac{\theta}{90^\circ}=\frac{45^\circ}{90^\circ}=0.5$
Now you may ask why I calculated $\theta$ when I already knew it was $45^\circ$, it was just to show the full working, in general you would have to find the angle first.
Random Example
Take 2 vectors say, $a = (0,5)$ and $b = (1,5)$ then
$\frac{a \cdot b}{|a||b|} = \frac{(0,5) \cdot (1,5)}{5\cdot\sqrt{26}} = \frac{25}{5\sqrt{26}}
$
So $\theta = \arccos{ \frac{25}{5\sqrt{26}}} = 11.31^\circ$ and therefore $\frac{\theta}{90^\circ}=\frac{11.31^\circ}{90^\circ}=0.125$
This looks like a good "percentage aligned" as $b$ is close to the x-axis and 0.125 is small.
Random Example 2
Take 2 vectors say, $a = (0,5)$ and $b = (5,1)$ then
$\frac{a \cdot b}{|a||b|} = \frac{(0,5) \cdot (5,1)}{5\cdot\sqrt{26}} = \frac{5}{5\sqrt{26}}
$
So $\theta = \arccos{ \frac{1}{\sqrt{26}}} = 78.69^\circ$ and therefore $\frac{\theta}{90^\circ}=\frac{78.69^\circ}{90^\circ}=0.874$
This looks like a good "percentage aligned" as $b$ is close to the y-axis and 0.874 is large.
Here (If this is what you are asking) tending to 0 would mean parallel and tending to 1 would be perpendicular.
