The line passes through the point A (It is labeled g in the attachment)

The line passes through the point B (It is labeled h in the attachment)

The equations of the lines are:

. The vector is the direction vector of and it is painted in blue.

. The vector is the direction vector of and it is painted in red.

The vector is the result of the cross product of the 2 direction vectors:

Use the unit vector of n: to calculate the distance d between the 2 lines: