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!