MCPcopy Create free account
hub / github.com/axmolengine/axmol / isLineIntersect

Method isLineIntersect

core/math/Vec2.cpp:238–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236}
237
238bool Vec2::isLineIntersect(const Vec2& A, const Vec2& B, const Vec2& C, const Vec2& D, float* S, float* T)
239{
240 // FAIL: Line undefined
241 if ((A.x == B.x && A.y == B.y) || (C.x == D.x && C.y == D.y))
242 {
243 return false;
244 }
245
246 const float denom = crossProduct2Vector(A, B, C, D);
247
248 if (denom == 0)
249 {
250 // Lines parallel or overlap
251 return false;
252 }
253
254 if (S != nullptr)
255 *S = crossProduct2Vector(C, D, C, A) / denom;
256 if (T != nullptr)
257 *T = crossProduct2Vector(A, B, C, A) / denom;
258
259 return true;
260}
261
262bool Vec2::isLineParallel(const Vec2& A, const Vec2& B, const Vec2& C, const Vec2& D)
263{

Callers

nothing calls this directly

Calls 1

crossProduct2VectorFunction · 0.85

Tested by

no test coverage detected