Okay what I did was that I found the distance between 2 points r = (x1-x2, y1-y2, z1-z2) and then generated a vector that is orthogonal to the 2 lines using cross product and projected r onto d (the distance). The problem I'm having is simplying the equation into the final equation. How do I simplify r.(u x v) into that 3x3 matrix?