Polygon.centroid()
See original GitHub issueDescribe the bug
Polygon.centroid
returns a strange value for a polygon with 4 points that is self interesecting (see image),
Using the same points (of the polygon), but cycled differently we get a polygon that is more conventional…
To Reproduce Steps to reproduce the behavior:
- Python script:
from compas.geometry.primitives import Polygon, Point
polygon1 = Polygon([Point(0.000, -5.536, 1977.967), Point(0.000, 144.352, -0.000), Point(0.000, -148.968, -0.000), Point(0.000, 264.624, 1977.967)])
polygon2 = Polygon([Point(0.000, 144.352, -0.000), Point(0.000, 264.624, 1977.967), Point(0.000, -5.536, 1977.967), Point(0.000, -148.968, -0.000)])
print(polygon1.centroid)
print(polygon2.centroid)
>>>>Point(0.000, -471.050, -7031.803)
>>>>Point(0.000, 62.715, 975.434)
Expected behavior I would expect them to have the same centroid.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Windows
- Python version 3.8.6
- Python package manager conda
- Compas version 1.0.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
Centroid - Wikipedia
In mathematics and physics, the centroid, also known as geometric center or center of figure, of a plane figure or solid figure is...
Read more >Centroid (Polygon)—ArcGIS Pro | Documentation
In a group template, the Centroid builder generates a point feature at the centroid of a primary polygon feature you create in a...
Read more >ee.Geometry.Polygon.centroid - Earth Engine
Returns a point at the center of the highest-dimension components of the geometry. Lower-dimensional components are ignored, so the centroid of ...
Read more >Finding the centroid of a polygon? - c++ - Stack Overflow
The formula is given here for vertices sorted by their occurance along the polygon's perimeter. For those having difficulty understanding ...
Read more >Find the centroid of a non-self-intersecting closed Polygon
Given N vertices of the polygon, the task is to find the centroid of the polygon. Examples: Input: ar = {{0, 0}, {0,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@gonzalocasas needs to be discussed in the next dev meeting…
will leave it open as a reminder that the current implementation can lead to unexpected results 😃