MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / line_line_distance

Function line_line_distance

code/geometry/primitives3d.cpp:87–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85 Q = P + n;
86 return true; }
87double line_line_distance(L(A, B), L(C, D), point3d &E,
88 point3d &F) {
89 point3d w = (C-A), v = (B-A), u = (D-C),
90 N = v*u, N1 = v*(u*v), N2 = u*(v*u);
91 if (w.isZero() || (v*w).isZero()) E = F = A;
92 else if (N.isZero()) E = A,
93 F = A + w - v * ((w%v)/(v%v));
94 else E = A + v*((w % N2)/(v%N2)),
95 F = C + u*(((-w) % N1)/(u%N1));
96 return (F-E).length(); }
97// vim: cc=60 ts=2 sts=2 sw=2:

Callers

nothing calls this directly

Calls 2

isZeroMethod · 0.80
lengthMethod · 0.80

Tested by

no test coverage detected