MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / computeLineLineCross

Function computeLineLineCross

source/MRMesh/MRSurfacePath.cpp:39–51  ·  view source on GitHub ↗

computes the intersection between 1) the infinite line passing through the origin with direction +-unitDir; 2) the infinite line containing the segment bc, returning in \param a the intersection position on that line. \return false if the segment bc is parallel to unitDir

Source from the content-addressed store, hash-verified

37/// 2) the infinite line containing the segment bc, returning in \param a the intersection position on that line.
38/// \return false if the segment bc is parallel to unitDir
39static bool computeLineLineCross( const Vector3f & b, const Vector3f & c, const Vector3f & unitDir, float & a )
40{
41 const auto d = c - b;
42 // gort is a vector in the triangle plane orthogonal to grad
43 const auto gort = d - dot( d, unitDir ) * unitDir;
44 //const auto god = dot( d, d ) - sqr( dot( d, unitDir ) );
45 const auto god = dot( gort, d );
46 if ( god <= 0 )
47 return false; // segment bc is parallel to unitDir
48 const auto gob = -dot( gort, b );
49 a = gob / god;
50 return true;
51}
52
53/// given triangle with scalar field increasing in the direction \param unitDir;
54/// returns true if the field increases inside the triangle from the edge 01

Callers 2

computeEnter01CrossFunction · 0.85
findSteepestDescentPointFunction · 0.85

Calls 1

dotFunction · 0.70

Tested by

no test coverage detected