[Math] the meaning of vector (A cross B) cross A

geometrylinear algebravectors

Answered (I think!):

The triple product's purpose is to find a direction to the origin, perpendicular to the baseline, which is super trivial in 2D as there is only two perpendicular orientations, but the "cylinder" distinction is made in 3D because there are infinite perpendicular orientations – hence the triple product. Diagram in one of the answers shows this nicely!

Original Question:

I was looking at a video explaining the G-J-K algorithm for finding the two closest features on two convex shapes – when it came to a bit about, given a line, what is the direction in 3D space, from a point on the line, which points to the origin. Seems easy enough: just invert the position vector to point backwards to the origin – and that's exactly what the code does in an earlier step of the algorithm. Bizarrely, they say that as "the origin could be in a cylinder around the line in 3D space", the direction to the origin is given by the following:

Let X be the vector between points A and B on the line (from A to B), and Y be the inverse position vector from A to the origin. The direction to the origin, apparently, is (X cross Y) cross X! I expanded this out, saw an interesting pattern but could not link it to the problem:

For two vectors A, B; (A cross B) cross A I found to be equal to:

Ax(AyBy + AzBz) – Bx(AyAy + AzAz)

Ay(AxBx + AzBz) – By(AxAx + AzAz)

Az(AxBx + AyBy) – Bz(AxAx + AyAy)

Notated as a column vector, with "Vn" meaning the Nth coordinate of vector V. By "cross" I mean the 3D cross product.

I know this isn't the computer science stack exchange – I would like the mathematical meaning of "(A cross B) cross A", and a reason why the code does this, and not just another inverse position vector as it did previously, to find a direction to the origin. Many thanks for any help, and I will repost this on a different stack if it's too offensive here!

Best Answer

Double cross product is a very common technique to project a vector onto the surface. Consider the triple product

$$-\vec{n} \times \vec{n} \times \vec{v}$$

where $\vec{n}$ is a normal vector to some surface. $\vec{n}$ is typically normalized, meaning that its length $|\vec{n}| = 1$. Any cross-product with a normal is going to be orthogonal to that normal, so it will land on the surface the normal is orthogonal to. It will also be orthogonal to the original $\vec{v}$. Now the second cross product will rotate the vector counter-clockwise 90 degrees, still within that surface. The result of that will be that it will now be parallel to $\vec{v}$ in some sense. More precisely, we will have obtained the projection of the vector $\vec{v}$ onto the surface, for which $\vec{n}$ is a normal. It turns out that the cross product rotates the vector in the wrong direction, so we also need to add a minus sign in front to correct for that.

enter image description here