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

◆ signed_area()

float MayaFlux::Kinesis::signed_area ( std::span< const glm::vec2 >  path)
inlinenoexcept

Signed area enclosed by treating the path as a closed polygon.

Parameters
pathPositions in chronological order, at least three
Returns
Shoelace area, positive for counterclockwise winding

Implicitly closes the path from its last point back to its first. Distinct from signed_turning as a direction measure: turning responds to the sequence of headings and stays large for a tight scribble that encloses nothing, while this responds to enclosure and stays near zero for a path that doubles back over itself regardless of how much it turned doing so.

Definition at line 139 of file PathShape.hpp.

140{
141 if (path.size() < 3)
142 return 0.0F;
143
144 float acc = 0.0F;
145 for (size_t i = 0; i < path.size(); ++i) {
146 const glm::vec2& a = path[i];
147 const glm::vec2& b = path[(i + 1) % path.size()];
148 acc += cross_2d(a, b);
149 }
150 return 0.5F * acc;
151}
size_t a
size_t b
float cross_2d(const glm::vec2 &a, const glm::vec2 &b) noexcept
2D scalar cross product, sign of turn direction

References a, b, and cross_2d().

+ Here is the call graph for this function: