First, transform the equation of the line into a symmetrical form to obtain its direction vector n1=(a1,b1,c1),n2=(a2,b2,c2).
Cross-product the two vectors to get their common perpendicular vector N = (x, y, z), select points A and B (arbitrary) on the two lines respectively, and get vector AB. The projection of vector AB in the direction of vector N is the distance between the two non-coplanar lines (that is, the shortest distance). Do you know how to calculate it?
d=|vector N*vector AB|/|vector N| (the above is the dot product of two vectors, the following is the modulus), let the intersection points be C and D, substitute them into the symmetry formula of the common perpendicular line N, and because the two points C and D satisfy the initial straight line equation respectively, we get two consecutive equations about C (or D), just solve them separately
formula: