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

Function line_line_intersect

code/geometry/primitives3d.cpp:64–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62 return
63 abs((A - *this) * (B - *this) % (C - *this)) < EPS; } };
64int line_line_intersect(L(A, B), L(C, D), point3d &O){
65 if (abs((B - A) * (C - A) % (D - A)) > EPS) return 0;
66 if (((A - B) * (C - D)).length() < EPS)
67 return A.isOnLine(C, D) ? 2 : 0;
68 point3d normal = ((A - B) * (C - B)).normalize();
69 double s1 = (C - A) * (D - A) % normal;
70 O = A + ((B - A) / (s1 + ((D - B) * (C - B) % normal))) * s1;
71 return 1; }
72int line_plane_intersect(L(A, B), PL(C, D, E), point3d & O) {
73 double V1 = (C - A) * (D - A) % (E - A);
74 double V2 = (D - B) * (C - B) % (E - B);

Callers

nothing calls this directly

Calls 3

lengthMethod · 0.80
isOnLineMethod · 0.80
normalizeMethod · 0.80

Tested by

no test coverage detected