First, transform the equation of the line into a symmetrical form to obtain its direction vector n1=(a1,b1,c1),n2=(a2,b2,c2).
Multiply the two vectors by cross to obtain their common perpendicular vector N=(x,y,z), select points A and B (arbitrary) on the two lines respectively, and obtain 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 scalar product of two vectors, the following is the modulus), let the intersection points be C and D, and substitute them into the symmetric formula of the common perpendicular line N. Since the two points C and D satisfy the initial straight line equation, we get two continuous equations about C (or D), and we can solve them separately.
Formula: