FastLine
Project description
FastLine
Python module for geometric Line operations implmented in C++ then binded to python, and it is optimized for speed. I created this module to use in a project where I needed to do many of such calculations.
installation
$ pip install FastLine
or
git clone https://github.com/MrGolden1/FastLine.git
cd FastLine
pip install .
usage
from FastLine import Line
# define a line by two points
l1 = Line(p1=(0,0), p2=(10,10))
# define a line by its slope and intercept
l2 = Line(m=4, b=-1)
methods:
solve: takes x or y as argument and return the corresponding value
>>> l1.solve(x=20)
20.0
>>> l2.solve(y=20)
5.25
distance_to: takes a point as argument and return the nearest distance to the line.
>>> l1.distance_to((20,50))
21.213203435596427
>>> l2.distance_to((-15,17))
18.91777875283397
crossed_by: takes a point as argument and return a value in [-1,0,1] (upon a specific side, upon the line, uopn opposite side). You'd need to calibrate what each side is.
>>> l1.crossed_by((20,50)) # specific side
1
>>> l1.crossed_by((50,50)) # on the line
0
>>> l1.crossed_by((-20,-50)) # opposite side
-1
intersection: takes a line as argument and return the intersection point. If two lines are parallel, it returns None.
>>> l1.intersection(l2)
(0.3333333333333333, 0.3333333333333333)
Thanks to:
https://stackoverflow.com/a/3838398/10220190
https://stackoverflow.com/a/39840218/10220190
https://stackoverflow.com/a/20679579/10220190
Author:M.Ali Zarrinzadeh
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file FastLine-1.1.tar.gz.
File metadata
- Download URL: FastLine-1.1.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/0.23 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b123b30381fafa733e638a6a39f967e660e32e4a01baff865eb1b3b701220c37
|
|
| MD5 |
2961efd92640b22abff4fcfb19202763
|
|
| BLAKE2b-256 |
74d9176421e9deef5885fc9877ef6fcf911dfbb745334334f3f164e5020c20ec
|
File details
Details for the file FastLine-1.1-cp37-cp37m-win_amd64.whl.
File metadata
- Download URL: FastLine-1.1-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 14.2 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/0.23 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
280add85c94d53fca2d6b2c1c1fa1f4f4880cc4f0fbebd635da03b64e7fd3fc0
|
|
| MD5 |
3861517821ab24320e566749602b2c40
|
|
| BLAKE2b-256 |
5ebd1c684f8cbb151d7abf35e29b79d0ef61ec1ca1a2912a5e4e91601ff1125a
|