Polygen2D: Polygen in 2D with Python.
Project description
Polygen2D
背景
在使用Python处理2D散点图时,发现当下Python库中对平面坐标系的少之又少,想要对点、线、多边形进行操作和判断实在不方便,Polygen2D应运而生,Polygen2D旨在解决2D平台下对散点的处理,将散点抽象为多边形等。
安装
这个项目基于Python3。请确保你本地安装的Python版本大于3。
$ pip install Polygen2D
$ # pip3 install Polygen2D # 如果使用的是pip3
示例
这里的参考程序通过Numpy生成了多边形数据点后生成对应的点、线和面来进行判断点是否在多边形内、计算点到线的距离。
from Polygen2D import Point, Line, Polygen
import numpy as np
x = np.array([0, 5, 5, 0])
y = np.array([0, 0, 5, 5])
points: [Point] = [] # 多边形点集
for i in range(len(x)):
points.append(Point(x=x[i],y=y[i]))
polygen = Polygen(points) # 多边形初始化
test_point1 = Point(x=1, y=1)
test_point2 = Point(x=-1, y=-1)
test_point3 = Point(x=5, y=2)
test_line = Line(test_point1, test_point2)
print("test_point1 In Polygen?", polygen.contain(test_point1)) # 判断test_point1是否在多边形内
print("test_point2 In Polygen?", polygen.contain(test_point2)) # 判断test_point2是否在多边形内
print("the distance between test_point3 and test_line:", test_line.distance(test_point3)) # 点test_point3到线test_line的距离
更多
如果想要将散点图生成具体图像可以借助matplotlib来实现。
维护者
如何贡献
非常欢迎你的加入!提一个 Issue 或者提交一个 Pull Request。
标准 Readme 遵循 Contributor Covenant 行为规范。
使用许可
MIT © Littleor
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Polygen2D-0.1.1.tar.gz
(3.8 kB
view details)
Built Distribution
File details
Details for the file Polygen2D-0.1.1.tar.gz
.
File metadata
- Download URL: Polygen2D-0.1.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d764d738213bca42be282663d0ed0e29830a2ef19a3cb4250ec806579622cf3 |
|
MD5 | 17a05fe01bfffe88285dd8d8b4b7fd78 |
|
BLAKE2b-256 | a6a22ead763ae0bb95eac1136d97372010f2b56a05d4e8b15f7218b51fdd593c |
File details
Details for the file Polygen2D-0.1.1-py2.py3-none-any.whl
.
File metadata
- Download URL: Polygen2D-0.1.1-py2.py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.6.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f57766285268e1aac127f7d2124b04db40e06bc4043f77fe13f304fcabd5e86 |
|
MD5 | 745de3a6a85e44c596b5bb41f95d2a62 |
|
BLAKE2b-256 | 19457d9e44f0f013fbab498c70aaa986ad7537f9c3d695d3aa72d8d8b1473bc2 |