Skip to main content

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

Email:ali.zarrinzadeh@gmail.com

Metadata

Release files for FastLine 1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for FastLine 1.1
File Size Uploaded
FastLine-1.1.tar.gz 5.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for FastLine 1.1
File Interpreter ABI Platform
FastLine-1.1-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details

Total release size: 20.0 kB

Release files / FastLine-1.1.tar.gz

Download URL FastLine-1.1.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b123b30381fafa733e638a6a39f967e660e32e4a01baff865eb1b3b701220c37
BLAKE2b-256 checksum
How to use checksums
74d9176421e9deef5885fc9877ef6fcf911dfbb745334334f3f164e5020c20ec
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / FastLine-1.1-cp37-cp37m-win_amd64.whl

Download URL FastLine-1.1-cp37-cp37m-win_amd64.whl
Size 14.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
280add85c94d53fca2d6b2c1c1fa1f4f4880cc4f0fbebd635da03b64e7fd3fc0
BLAKE2b-256 checksum
How to use checksums
5ebd1c684f8cbb151d7abf35e29b79d0ef61ec1ca1a2912a5e4e91601ff1125a
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.1 This release

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page