MCPcopy Create free account
hub / github.com/BIMCoderLiang/LNLib / ComputeLineAndPlane

Method ComputeLineAndPlane

src/LNLib/Algorithm/Intersection.cpp:74–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72}
73
74LinePlaneIntersectionType LNLib::Intersection::ComputeLineAndPlane(
75 const XYZ& normal,
76 const XYZ& pointOnPlane,
77 const XYZ& pointOnLine,
78 const XYZ& lineDirection,
79 XYZ& intersectPoint)
80{
81 double denom = lineDirection.DotProduct(normal);
82
83 XYZ P0Q = pointOnLine - pointOnPlane;
84 double numer = -P0Q.DotProduct(normal);
85
86 if (MathUtils::IsAlmostEqualTo(std::abs(denom),0.0)) {
87 if (MathUtils::IsAlmostEqualTo(std::abs(numer), 0.0)) {
88 intersectPoint = pointOnLine;
89 return LinePlaneIntersectionType::On;
90 }
91 else {
92 return LinePlaneIntersectionType::Parallel;
93 }
94 }
95
96 double t = numer / denom;
97 intersectPoint = pointOnLine + t * lineDirection;
98 return LinePlaneIntersectionType::Intersecting;
99}

Callers

nothing calls this directly

Calls 1

DotProductMethod · 0.45

Tested by

no test coverage detected