I’m going to now very quickly repeat everything above but directly in 2D. If someone wants an informal visualization aid then let me know. We have two vectors ‘a’ & ‘b’ (directions or coordinates) in N dimensions (but let’s think 3…the number doesn’t matter). We visualize the vectors in the standard way: tails starting from some origin and their magnitude as a length with little arrows drawn at the end. Assuming that ‘a’ and ‘b’ are not pointing in the same or opposite directions (in the visualization they don’t fall on the same line), then there is a plane which contains both of them. We’re using ‘a’ as our reference direction so it falls on the positive x-axis. For our positive ‘y’ axis we’re going to choose the direction that contains ‘b’. We’re forcing the visualization of ‘b’ to be above the x-axis (in the first or second quadrant). From the head of ‘b’ (the tip of the arrow), we can draw a vertical line to the x-axis and label the point it cross as ‘px’. Likewise we can draw a horizontal line and label the point it cross the y-axis as ‘py’. These values are: px = parallel projection of ‘b’ onto the x-axis and parallel projection of ‘b’ onto the y-axis. These two values give us a local 2D coordinate of ‘b’.
So in this local 2D coordinate system we have (assuming b is unit, |b|=1):
a = |a|(1,0)
b = |b|(px,py)
if ‘b’ isn’t unit then the |b| is already contained in our px and py. Showing it this way because we can also express ‘b’ as:
b = |b|(cos(t), sin(t))
From this point of view what the trig operations are really saying is: cos(t) = how much is in ‘x’ and sin(t) = how much is in ‘y’. Now I’m really still making this overly complicated because I attempt to give a picture of how the pieces fit together. Now we’re ready for the punch-line:
Let X=|b|px, Y=|b|py and H=|b|
X2+Y2=H2 or (s cos(t))2+(s sin(t))2 = s2
So we’ve done a long dog-and-pony show to derive: Pythagorean theorem
The Pythagorean theorem doesn’t care about the scale of things. The relation is independent of uniform scaling. Given two of values we can find the third. The only higher order math notion required is the dot product which is typically shown as:
(a·b) = |a||b|cos(t)
which is a parallel projection(1) of b onto a , which is a scaled parallel projection onto the local x-axis. This extra scale factor of |a| doesn’t matter since the Pythagorean theorem doesn’t care about it. That gives us a ‘how much in x’ and we know the magnitude of ‘b’ so our unknown is ‘how much in y’. Solve for Y:
X2+Y2 = H2 -> Y2 = H2 - X2
X2 =(a·b)2
H2 = (a·a)(b·b)
Y2 = (a·a)(b·b) - (a·b)2
H may not be immediately clear. (b·b) is the magnitude squared of ‘b’. The magnitude of ‘a’ squared (a·a) is being multiplied in to account for the extra scaling on X.
Now for some other parts. If we wanted to know the unit vector in the direction of the positive ‘x’ axis then it’s simply: a/|a|. Now what about the same for ‘y’? Let’s do the dog-and-pony vector version.
(a×b) would give us a vector orthogonal to the local plane. Then if we cross that again with ‘a’ would give us the direction of ‘y’. So: (a×b)×a.
This is a form of the vector triple product: (a×b)×c = (a·c)b - (b·c)a
So our ‘y’ direction is: (a×b)×a = (a·a)b - (b·a)a = (a·a)b - (a·b)a
if |a| = 1, then (a·a)=1 and it would be: b - (a·b)a
the (a·b) is “how much in X” which we multiply by ‘a’ to get it back into a direction instead of a scalar. And we’re subtracting that from ‘b’. The end result is we’re taking ‘b’ and removing the part of it that’s in the ‘x’ direction. Or in other words we’re zeroing out the x-component in the local coordinate system. When |a| isn’t 1 then the extra (a·a) is accounting for the scaling introduced by (a·b). The magnitude of the computed Y direction is Pythagorean result above.
Yeah I could have made this easier to understand, but it’s already long enough. If something isn’t clear and you care then ask.
(1) Or ‘a’ onto ‘b’…the projection is the same.