Skip to content

Commit

Permalink
Merge pull request #92154 from lawnjelly/is_polygon_clockwise_doc
Browse files Browse the repository at this point in the history
Clarify `is_polygon_clockwise()` coordinate system
  • Loading branch information
akien-mga committed May 21, 2024
2 parents 149e3b8 + 331ecf3 commit dcc7cb0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/math/geometry_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ class Geometry2D {
return triangles;
}

// Assumes cartesian coordinate system with +x to the right, +y up.
// If using screen coordinates (+x to the right, +y down) the result will need to be flipped.
static bool is_polygon_clockwise(const Vector<Vector2> &p_polygon) {
int c = p_polygon.size();
if (c < 3) {
Expand Down
1 change: 1 addition & 0 deletions doc/classes/Geometry2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
<param index="0" name="polygon" type="PackedVector2Array" />
<description>
Returns [code]true[/code] if [param polygon]'s vertices are ordered in clockwise order, otherwise returns [code]false[/code].
[b]Note:[/b] Assumes a Cartesian coordinate system where [code]+x[/code] is right and [code]+y[/code] is up. If using screen coordinates ([code]+y[/code] is down), the result will need to be flipped (i.e. a [code]true[/code] result will indicate counter-clockwise).
</description>
</method>
<method name="line_intersects_line">
Expand Down

0 comments on commit dcc7cb0

Please sign in to comment.