paralleldomain.model.geometry.polyline_2d

exception CollinearLinesException
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class Line2DBaseGeometry(start, end)

Represents a 2D Line.

Parameters:
start

the 2D start point of the line in image coordinates

end

the 2D end point of the line in image coordinates

directed

whether the line is directed from start to end (if False the line is bi-directional)

class_id

Class ID of the line. Can be used to lookup more details in ClassMap.

instance_id

Instance ID of annotated object. Can be used to cross-reference with other instance annotation types, e.g., InstanceSegmentation2D or InstanceSegmentation3D. If unknown defaults to -1.

attributes

Dictionary of arbitrary object attributes.

intersects_at(other)

Returns the point at which the two lines intersect and a bool value that indicated if the intersection point is within the line segments. Returns None if the lines are parallel. See: https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect

Return type:

Tuple[Optional[Point2DBaseGeometry[TypeVar(T, int, float)]], bool, bool]

Parameters:

other (Line2DBaseGeometry[T]) –

to_numpy()

Returns the start and end coordinates as a numpy array with shape (2 x 2).

Return type:

ndarray

property direction: Point2DBaseGeometry[T]

Returns the directional vector of the line.

property length: float

Returns the length of the line.

property slope: float

Returns the slope of the line. Returns np.inf for vertical lines.

class Line2DGeometry(start, end)
Parameters:
intersects_at(other)

Returns the point at which the two lines intersect and a bool value that indicated if the intersection point is within the line segments. Returns None if the lines are parallel. See: https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect

Return type:

Tuple[Optional[Point2DBaseGeometry[TypeVar(T, int, float)]], bool, bool]

Parameters:

other (Line2DBaseGeometry[T]) –

to_numpy()

Returns the start and end coordinates as a numpy array with shape (2 x 2).

Return type:

ndarray

property direction: Point2DBaseGeometry[T]

Returns the directional vector of the line.

property length: float

Returns the length of the line.

property slope: float

Returns the slope of the line. Returns np.inf for vertical lines.

class Polyline2DBaseGeometry(lines)

A polyline made of a collection of 2D Lines

Parameters:

lines (List[Line2DBaseGeometry[TypeVar(T, int, float)]]) – lines

lines

Ordered list of Line2D instances

to_numpy()

Returns all ordered vertices as a numpy array of shape (N x 2).

property length

Returns the length of the line.

class Polyline2DGeometry(lines)
Parameters:

lines (List[Line2DBaseGeometry[T]]) –

to_numpy()

Returns all ordered vertices as a numpy array of shape (N x 2).

property length

Returns the length of the line.