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

Function findIntersection

source/MRMesh/MROffsetContours.cpp:184–198  ·  view source on GitHub ↗

returns intersection point of (a->b)x(c->d) nullopt if parallel

Source from the content-addressed store, hash-verified

182// returns intersection point of (a->b)x(c->d)
183// nullopt if parallel
184std::optional<Vector2f> findIntersection( const Vector2f& a, const Vector2f& b, const Vector2f& c, const Vector2f& d )
185{
186 auto vecA = b - a;
187 if ( cross( vecA, d - c ) == 0.0f )
188 return std::nullopt;
189
190 auto abcS = cross( c - a, vecA );
191 auto abdS = cross( vecA, d - a );
192
193 auto sum = abcS + abdS;
194 if ( sum == 0.0f )
195 return std::nullopt;
196 auto ratio = abcS / sum;
197 return c * ( 1.0f - ratio ) + d * ratio;
198}
199
200void insertRoundCorner( Contour2f& cont, const CornerParameters& params, float minAnglePrecision, int* shiftMap )
201{

Callers 1

insertSharpCornerFunction · 0.85

Calls 1

crossFunction · 0.70

Tested by

no test coverage detected