Skip to main content

Actions Status

PyPi versions PyPi Download stats

Line clipping

  • lineclipping.f90 Cohen-Sutherland line clipping algorithm for massively parallel coarray modern Fortran. Input scalars or arrays, output intersections or NaN if no intersection.
  • lineClipping.py Cohen-Sutherland line clipping algorithm for Python. Input scalars, output intersection length, or None if no intersection.

Julia line clipping is at https://github.com/scivision/lineclipping-julia

Install

To install the latest release:

pip install pylineclip

Fortran

If you want to use the Fortran Cohen-Sutherland line clipping modules directly (optional):

meson build

meson test -C build

Usage

The main difference with textbook implementations is that I return a sentinel value (NaN, None, nothing) if there's no intersection of line with box.

Python

import pylineclip.lineclipping as lc

x3,y3,x4,y4 = lc.cohensutherland((xmin, ymax, xmax, ymin, x1, y1, x2, y2)

If no intersection, (None, None, None, None) is returned.

Fortran

lineclipping.f90 has two subroutines. Pick Ccohensutherland if you're calling from C/C++/Python, which cannot tolerate assummed-shape arrays. It's a slim wrapper to cohensutherland which is elemental (can handle scalar or any rank array).

Fortran programs will simply use

use lineclipping
call cohensutherland(xmin,ymax,xmax,ymin,x1,y1,x2,y2)

The arguments are:

INPUTS
------
xmin,ymax,xmax,ymin:  upper left and lower right corners of box (pixel coordinates)

INOUT
-----
x1,y1,x2,y2:
in - endpoints of line
out - intersection points with box. If no intersection, all NaN

Metadata

Release files for pylineclip 1.0.0

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

Source distribution (sdist)

Source distribution for pylineclip 1.0.0
File Size Uploaded Provenance Actions
pylineclip-1.0.0.tar.gz 4.8 kB Without provenance Details for pylineclip-1.0.0.tar.gz

Release files / pylineclip-1.0.0.tar.gz

Download URL pylineclip-1.0.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8c1506df20de89e7ff0b631e48572314c77adc4b20de549c0c4e328cc98374d3
BLAKE2b-256 checksum
How to use checksums
2eeddabd4cc3d7c666c6980787bb1ec3ff72ca275a0e157a550048cac60b9f4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Security for pylineclip 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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