compas-dev / compas-dev/compas

Polygon.centroid()

Open
#777 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
386
Forks
122
Avg merge
11d 46m
Merged PRs (30d)
1

Description

**Describe the bug**
`Polygon.centroid` returns a strange value for a polygon with 4 points that is self interesecting (see image),
![image](https://user-images.githubusercontent.com/17108767/109140428-e05fbf80-775c-11eb-86b6-5f85b4c951bf.png)

Using the same points (of the polygon), but cycled differently we get a polygon that is more conventional...
![image](https://user-images.githubusercontent.com/17108767/109140636-169d3f00-775d-11eb-982b-449e59698177.png)

**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)])

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.