MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ triangle_contains()

bool MayaFlux::Kinesis::triangle_contains ( glm::vec2 p,
glm::vec2 a,
glm::vec2 b,
glm::vec2 c )
inlinenodiscardnoexcept

Whether a point lies inside or on a triangle, whichever way it winds.

Note
A degenerate triangle with collinear corners contains only points on its line.

Definition at line 512 of file Bounds.hpp.

514{
515 const auto cross = [](glm::vec2 u, glm::vec2 v) { return u.x * v.y - u.y * v.x; };
516 const float d1 = cross(b - a, p - a);
517 const float d2 = cross(c - b, p - b);
518 const float d3 = cross(a - c, p - c);
519 const bool negative = d1 < 0.0F || d2 < 0.0F || d3 < 0.0F;
520 const bool positive = d1 > 0.0F || d2 > 0.0F || d3 > 0.0F;
521 return !(negative && positive);
522}

Referenced by triangle_list_bounds().

Here is the caller graph for this function: