Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.


See original GitHub issue

Issue Description

Describe the bug Polygon.centroid returns a strange value for a polygon with 4 points that is self interesecting (see image), image

Using the same points (of the polygon), but cycled differently we get a polygon that is more conventional… image

To Reproduce Steps to reproduce the behavior:

  1. 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)])

>>>>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:open
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

brgcodecommented, Feb 25, 2021

@gonzalocasas needs to be discussed in the next dev meeting…

brgcodecommented, Feb 25, 2021

will leave it open as a reminder that the current implementation can lead to unexpected results 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found