pyinterp.geometry.cartesian.Segment

Contents

pyinterp.geometry.cartesian.Segment#

class pyinterp.geometry.cartesian.Segment(self)#
class pyinterp.geometry.cartesian.Segment(self, a: tuple[float, float] | None = None, b: tuple[float, float] | None = None)

Bases: object

A segment in Cartesian coordinates.

A Segment is defined by two endpoints (points) on a flat plane.

Examples

>>> from pyinterp.geometry.cartesian import Segment
>>> s = Segment((0.0, 0.0), (10.0, 5.0))
>>> len(s)
2

Overloaded function.

  1. __init__(self) -> None

Construct an empty segment.

  1. __init__(self, a: tuple[float, float] | None = None, b: tuple[float, float] | None = None) -> None

Construct a segment from two endpoints or four coordinates.

Parameters:
  • a – a tuple of two floats representing the first endpoint as x, y.

  • b – a tuple of two floats representing the second endpoint as x, y.

Attributes

a

First endpoint.

b

Second endpoint.

Public Methods

to_arrays(self)

Get the coordinate arrays of the segment endpoints.

Special Methods

__bool__(self)

Return True if the segment has non-default endpoints.

__eq__(self, other)

Check if two segments are equal.

__getitem__(self, idx)

Get endpoint at index (0 or 1).

__getstate__(self)

Return the state of the segment for pickling.

__len__(self)

Return the number of endpoints (always 2).

__ne__(self, other)

Check if two segments are not equal.

__new__(*args, **kwargs)

__repr__(self)

Return the official string representation of the segment.

__setitem__(self, idx, point)

Set endpoint at index (0 or 1).

__setstate__(self, state)

Restore the state of the segment from pickling.

__str__(self)

Return the informal string representation of the segment.