10.1.4.10. Primitive

Module to implement base classes for geometric primitives.

class Patro.GeometryEngine.Primitive.ClosedPrimitiveMixin[source]

Bases: object

closed_point_array

Return the geometry matrix as a Numpy array for a closed primitive.

\[\begin{split}\mathrm{Geometry\ Matrix} = \begin{bmatrix} x_0 & x_1 & \ldots & x_{n-1} & x_0 \\ y_0 & y_1 & \ldots & y_{n-1} & y_0 \end{bmatrix}\end{split}\]
closed_points
is_closed

True if the primitive is a closed path.

class Patro.GeometryEngine.Primitive.PathMixin[source]

Bases: object

to_path()[source]
class Patro.GeometryEngine.Primitive.PointPrimitive[source]

Bases: Patro.GeometryEngine.Primitive.Primitive

Base class for geometric primitive which are only defined by a list of points, like segment, polygon and Bézier curve.

Conversely an ellipse is defined by a centre, a scale-rotation matrix (a radius vector and a rotation angle) and an angular domain. Path is also another type of primitive which is a composition of basic primitives.

__eq__(other)[source]

Return self==value.

__hash__ = None
__len__()[source]

Array interface: return the number of points.

__repr__()[source]

Return repr(self).

_set_points(points)[source]
apply_transformation(transformation)[source]

Apply a transformation to the primitive.

If clone is set then the primitive is cloned.

bounding_box

Bounding box of the primitive.

Return None if primitive is infinite.

clone()[source]

Clone a primitive instance.

Warning

points must be cloned as well.

is_point_close(other)[source]
is_point_equal(other)[source]
is_reversible

True if the order of the points is reversible

mirror(clone=False)[source]
number_of_points

Number of points which define the primitive.

point_array

Return the geometry matrix as a Numpy array.

\[\begin{split}\mathrm{Geometry\ Matrix} = \begin{bmatrix} x_0 & x_1 & \ldots & x_{n-1} \\ y_0 & y_1 & \ldots & y_{n-1} \end{bmatrix}\end{split}\]
points

Usually return an iterator on the points.

reverse()[source]
rotate(angle, clone=False)[source]
scale(x_factor, y_factor=None, clone=False)[source]
transform(transformation, clone=False)[source]

Apply a transformation to the primitive.

If clone is set then the primitive is cloned.

x_mirror(clone=False)[source]
y_mirror(clone=False)[source]
class Patro.GeometryEngine.Primitive.PolygonMixin[source]

Bases: object

to_polygon()[source]
class Patro.GeometryEngine.Primitive.Primitive[source]

Bases: object

Base class for geometric primitive

__vector_cls__ = None
bounding_box

Bounding box of the primitive.

Return None if primitive is infinite.

clone()[source]

Clone a primitive instance.

dimension

Dimension in [2, 3] for 2D / 3D primitive

is_closed

True if the primitive is a closed path.

Note: an infinite primitive cannot be closed.

is_composed

True if the primitive is a composition of simpler primitives, e.g. a path.

is_infinite

True if the primitive has infinite extend like a line.

Note: a closed primitive cannot be infinite.

class Patro.GeometryEngine.Primitive.Primitive1P(p0)[source]

Bases: Patro.GeometryEngine.Primitive.PointPrimitive, Patro.GeometryEngine.Primitive.Primitive1PMixin

Base class to construct 2, 3, … points primitives.

_set_points(points)[source]
number_of_points

Number of points which define the primitive.

points

Usually return an iterator on the points.

reversed_points
class Patro.GeometryEngine.Primitive.Primitive1PMixin(p0)[source]

Bases: object

__init__(p0)[source]

Initialize self. See help(type(self)) for accurate signature.

p0
class Patro.GeometryEngine.Primitive.Primitive2DMixin[source]

Bases: object

Mixin for 2D primitive

__vector_cls__

alias of Patro.GeometryEngine.Vector.Vector2D

dimension
class Patro.GeometryEngine.Primitive.Primitive2P(p0, p1)[source]

Bases: Patro.GeometryEngine.Primitive.Primitive1P, Patro.GeometryEngine.Primitive.ReversiblePrimitiveMixin

Base class for 2-points primitives.

__init__(p0, p1)[source]

Initialize self. See help(type(self)) for accurate signature.

_set_points(points)[source]
end_point
interpolate(t)[source]

Return the linear interpolate of two points.

number_of_points

Number of points which define the primitive.

p1
points

Usually return an iterator on the points.

reversed_points
start_point
class Patro.GeometryEngine.Primitive.Primitive3P(p0, p1, p2)[source]

Bases: Patro.GeometryEngine.Primitive.Primitive2P

Base class for 3-points primitives.

__init__(p0, p1, p2)[source]

Initialize self. See help(type(self)) for accurate signature.

_set_points(points)[source]
end_point
iter_from_second_point()[source]
number_of_points

Number of points which define the primitive.

p2
points

Usually return an iterator on the points.

reversed_points
class Patro.GeometryEngine.Primitive.Primitive4P(p0, p1, p2, p3)[source]

Bases: Patro.GeometryEngine.Primitive.Primitive3P

Base class for 4-points primitives.

__init__(p0, p1, p2, p3)[source]

Initialize self. See help(type(self)) for accurate signature.

_set_points(points)[source]
end_point
iter_from_second_point()[source]
number_of_points

Number of points which define the primitive.

p3
points

Usually return an iterator on the points.

reversed_points
class Patro.GeometryEngine.Primitive.PrimitiveNP(*points)[source]

Bases: Patro.GeometryEngine.Primitive.PointPrimitive, Patro.GeometryEngine.Primitive.ReversiblePrimitiveMixin

Base class for N-points primitives.

__getitem__(_slice)[source]
__init__(*points)[source]

Initialize self. See help(type(self)) for accurate signature.

_set_points(points)[source]
end_point
static handle_points(points)[source]
iter_from_second_point()[source]
iter_on_nuplets(size)[source]
number_of_points

Number of points which define the primitive.

points

Usually return an iterator on the points.

reversed_points
start_point
class Patro.GeometryEngine.Primitive.ReversiblePrimitiveMixin[source]

Bases: object

end_point
is_reversible
reverse()[source]
reversed_points
start_point