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

Method PointToLine

src/LNLib/Algorithm/Projection.cpp:25–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25bool LNLib::Projection::PointToLine(const XYZ& start, const XYZ& end, const XYZ& point, XYZ& projectPoint)
26{
27 XYZ direction = end - start;
28 double lenSqr = direction.DotProduct(direction);
29
30 if (MathUtils::IsAlmostEqualTo(lenSqr, 0.0)) {
31 return false;
32 }
33
34 double t = (point - start).DotProduct(direction) / lenSqr;
35
36 if (MathUtils::IsLessThan(t, 0.0) ||
37 MathUtils::IsGreaterThan(t, 1.0)) {
38 return false;
39 }
40
41 projectPoint = start + t * direction;
42 return true;
43}
44
45LNLib::XYZ LNLib::Projection::Stereographic(const XYZ& pointOnSphere, double radius)
46{

Callers

nothing calls this directly

Calls 1

DotProductMethod · 0.45

Tested by

no test coverage detected