luogu-dev / luogu-dev/cyaron

Polygon 无法正确计算非简单多边形(有自交)的面积

Open
#138 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.7k
Forks
182
PR merge metrics
No merged PRs in 30d

Description

无法正确计算非简单多边形(有自交)的面积

```python
from cyaron import *

p = Polygon(
[(-3, 4), (1.5, 3), (-6, -2), (-3, -4)]
)
print(p.area()) # output: 3.0
```

如图,显然面积为 $15$。

![2024-10-04_19-08](https://github.com/user-attachments/assets/8eb3c752-11ee-4313-9dff-a60c135a0015)

即使这种情形在应用时不常见,是否应在文档中警告,或者在代码逻辑中加入判断?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the example by calling Polygon.area() with the provided self-intersecting points, then inspect the Polygon.area() entry point and its existing tests, if any. Define the intended behavior for self-intersecting polygons and document or implement that decision; done means the behavior is explicit and the example is covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.