Skip to main content

No project description provided

Project description

offset_poly

Move a polyline or polygon (left) by a given offset.

A counterclockwise polygon will be offset to the inside. I clockwise polygon will be offset to the outside.

offset_polygon

def offset_polygon(polyline: Sequence[_Vec2], offset: float) -> list[_Vec2]:
    """Offset polygon edges (to the left) by a constant amount.

    :param polyline: polyline
    :param offset: distance to offset from each edge
    :return: polygon offset by offset
    """

offset_polyline

def offset_polyline(polyline: Sequence[_Vec2], offset: float) -> list[_Vec2]:
    """Offset polygon edges (to the left) by a constant amount.

    :param polyline: polyline
    :param offset: distance to offset from each edge
    :return: polyline offset by offset
    """

The difference between the two is that offset_polygon will close the polygon if it is not already closed, whereas offset_polyline will leave the polyline open even if the first and last points are identical.

This package is the simplest version of polyline offsetting, it does not anticipate or account for self intersections that may come up when offsetting a polyline.

This is not nearly as sophisticated as curve offsetting, but you can use this for control polygon offsetting, which will be nearly as good in some instances.

  • multiple points (knots in your control points) are preserved.
  • if input[0] == input[-1], output[0] will equal output[-1]

You may see (nan, nan) in the result.

If you pass two adjacent, opposite, parallel edges, you will get a (nan, nan) in the result. With points A -> B -> A, for instance, there is no point that would be any given distance (except 0) left of both A B and B A.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

offset_poly-0.1.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

offset_poly-0.1.0-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file offset_poly-0.1.0.tar.gz.

File metadata

  • Download URL: offset_poly-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Windows/10

File hashes

Hashes for offset_poly-0.1.0.tar.gz
Algorithm Hash digest
SHA256 666628d825003aaadb35cdf667f4126a4bd3f18839c1175bdeed2fbe12930f80
MD5 ff63f2cc3a3f40386f207c2cd1ce2c8d
BLAKE2b-256 2568777f8f70ed89624739a32bf4ae682e1fb93543c3a732b7a84caf7d7ada7c

See more details on using hashes here.

File details

Details for the file offset_poly-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: offset_poly-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Windows/10

File hashes

Hashes for offset_poly-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 161ccbc86991c43be6c18b752e6504d196f5398ceb4c474f48061c400d6c5aec
MD5 5c056546dabf180ab5ef503569949831
BLAKE2b-256 3d6387495f22569f438c1a5b9d01e35281cb12ccf9b3055ca021ab5a19e64133

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page