6 const int32_t n = polygon.size();
11 double signedAreaSum = 0.0f;
13 for (int32_t i = 0; i < n; ++i) {
14 const auto& [x1, y1] = polygon.at(i);
15 const auto& [x2, y2] = polygon.at((i + 1) % n);
16 signedAreaSum += x1 * y2 - x2 * y1;
19 constexpr double epsilon = 1e-9;
21 if (signedAreaSum > epsilon) {
24 if (signedAreaSum < -epsilon) {
31 const int32_t n = polygon.size();
36 double signedAreaSum = 0.0f;
38 for (int32_t i = 0; i < n; ++i) {
39 const tmx::Vector2f& p1 = polygon.at(i);
40 const tmx::Vector2f& p2 = polygon.at((i + 1) % n);
42 signedAreaSum += p1.x * p2.y - p2.x * p1.y;
45 constexpr double epsilon = 1e-9;
47 if (signedAreaSum > epsilon) {
50 if (signedAreaSum < -epsilon) {
61 return "Clockwise (CW)";
63 return "Counter-Clockwise (CCW)";
79 return std::string(
"(") + std::to_string(vec.x) + std::string(
", ") + std::to_string(vec.y) + std::string(
")");
#define CORI_PIXELS_PER_METER
Anything connected to physics is in this namespace. Please refer to Box2D docs 'https://box2d....
b2Vec2 Vec2
An alias for Box2D native vec2 type, if you see it somewhere, be sure data there is in meters contrar...
glm::vec2 ToPixels(const Vec2 vec)
Converts physical meters to camera space pixels.
WindingOrder GetPolygonWindingOrder(const std::vector< Vec2 > &polygon)
Calculates the winding order of the polygon made up from individual points. Box2D version....
const char * WindingOrderToString(const WindingOrder order)
Converts the WindingOrder enumerator to string, for logging.
std::string Vec2ToString(const Vec2 vec)
Converts a native Box2D vec2 to string, for logging.
Vec2 ToMeters(const glm::vec2 vec)
Converts camera space pixels to physical meters.