How can I find distance between two skew lines?

In this code, I want to calculate distance between two lines SC and AB.

Clear["Global*"];
assumptions = {a > 0, h > 0};
{aa, bb, cc} = SSSTriangle[a, a, a][[1]];
{pA, pB, pC} = PadRight[#, 3] & /@ {aa, bb, cc};
pS = {0, 0, h};
Simplify[
RegionDistance[InfiniteLine[{pS, pC}], InfiniteLine[{pA, pB}]],
Assumptions -> assumptions]


I only got

How can I get the result?

PS. I work around

Clear["Global*"];
assumptions = {a > 0, b > 0, c > 0, h > 0};
{aa, bb, cc} = SSSTriangle[a, a, a][[1]];
{pA, pB, pC} = PadRight[#, 3] & /@ {aa, bb, cc};
pS = {0, 0, h};
plane = InfinitePlane[pA, {pC - pS, pB - pA}];
Simplify[RegionDistance[plane, pC], Assumptions -> assumptions]


and got

(Sqrt[3] a h)/Sqrt[3 a^2 + 4 h^2]

• Second argument of RegionDistance should be a point. Commented May 8 at 11:40
• RegionDistance not always work for two regions for symbolic. MinValue[ Norm[{x, y, z} - {u, v, w}], {x, y, z} ∈ InfiniteLine[{pS, pC}] && {u, v, w} ∈ InfiniteLine[{pA, pB}], {x, y, z, u, v, w}] Commented May 8 at 12:13
• @azerbajdzan, please read the documentation for RegionDistance. The second usage case is RegionDistance[reg1,reg2]. Commented May 8 at 12:14
• @Domen Mr. "I-know-It-All" please read documentation of RegionDistance for version 13. reference.wolfram.com/legacy/language/v13/ref/… Commented May 8 at 13:08

In 3D the minimum distance between the two lines can be expressed by the cross product as follows:

Abs[Dot[Normalize[Cross[pB - pA, pC - pS]], pS - pA]]


Note, that this formula is only correct if Cross[pB - pA, pC - pS] is not the zero vector. If it vanishes, then the lines are either parallel and coplanar or identical.

You may define a point on a line from pS to pC and a second point on a line from pA to pB and minimize the distance between house points:

line1[t_] = pS + t  (pC - pS);
line2[t_] = pA + t  (pB - pA);

Minimize[{Norm[line1[t1] - line2[t2]], a > 0, h > 0}, {t1, t2}]


As you can see, MMA gives a reasonable solution and a second one with an infinite distance. It is not clear to me, wherefrom this second solution comes.

It's slightly weird that it does not work, since it works if we rewrite RegionDistance for two regions as explained in the documentation:

RegionDistance[reg1,reg2] is effectively given by MinValue[Norm[p-q],{p∈reg1,q∈reg2}].

regionDistance[reg1_, reg2_] := MinValue[Norm[p - q], {p ∈ reg1, q ∈ reg2}]

regionDistance[InfiniteLine[{pS, pC}], InfiniteLine[{pA, pB}]]