Geometry
momapy.geometry
Geometric primitives and transformations for momapy.
This module provides geometric classes and functions for working with points, lines, segments, curves, and transformations. It includes support for Bezier curves, elliptical arcs, and various geometric operations.
Examples:
Classes:
| Name | Description |
|---|---|
Bbox |
Represents a bounding box. |
BezierCurve |
Represents a cubic Bezier curve. |
EllipticalArc |
Represents an elliptical arc. |
GeometryObject |
Abstract base class for all geometry objects. |
Line |
Represents an infinite line defined by two points. |
MatrixTransformation |
Represents a transformation as a 3x3 matrix. |
Point |
Represents a 2D point with x and y coordinates. |
Rotation |
Represents a rotation transformation. |
Scaling |
Represents a scaling transformation. |
Segment |
Represents a line segment between two points. |
Transformation |
Abstract base class for geometric transformations. |
Translation |
Represents a translation transformation. |
Functions:
| Name | Description |
|---|---|
are_lines_coincident |
Check if two lines are coincident. |
are_lines_parallel |
Check if two lines are parallel. |
get_angle_at_fraction_of_bezier_curve |
Get angle at a fraction along a Bezier curve. |
get_angle_at_fraction_of_elliptical_arc |
Get angle at a fraction along an elliptical arc. |
get_angle_at_fraction_of_segment |
Get angle at a fraction along a segment. |
get_angle_between_segments |
Get angle between two segments. |
get_angle_to_horizontal_of_line |
Get angle of a line relative to horizontal. |
get_angle_to_horizontal_of_point |
Get angle from origin to point relative to horizontal. |
get_center_of_elliptical_arc |
Get center of an elliptical arc. |
get_center_parameterization_of_elliptical_arc |
Get center parameterization of an elliptical arc. |
get_distance_between_line_and_point |
Get perpendicular distance from a point to a line. |
get_distance_between_points |
Get distance between two points. |
get_distance_between_segment_and_point |
Get shortest distance from a point to a segment. |
get_intersection_of_line_and_bezier_curve |
Get intersection of a line and a Bezier curve. |
get_intersection_of_line_and_elliptical_arc |
Get intersection of a line and an elliptical arc. |
get_intersection_of_line_and_point |
Get intersection of a line and a point. |
get_intersection_of_line_and_segment |
Get intersection of a line and a segment. |
get_intersection_of_line_and_shapely_object |
Get intersection of a line with a shapely object. |
get_intersection_of_lines |
Get intersection of two lines. |
get_normalized_angle |
Normalize an angle to [0, 2*pi). |
get_position_and_angle_at_fraction_of_bezier_curve |
Get position and angle at a fraction along a Bezier curve. |
get_position_and_angle_at_fraction_of_elliptical_arc |
Get position and angle at a fraction along an elliptical arc. |
get_position_and_angle_at_fraction_of_segment |
Get position and angle at a fraction along a segment. |
get_position_at_fraction_of_bezier_curve |
Get point at a fraction along a Bezier curve. |
get_position_at_fraction_of_elliptical_arc |
Get point at a fraction along an elliptical arc. |
get_position_at_fraction_of_segment |
Get point at a fraction along a segment. |
get_shapely_object_anchor_point |
Get an anchor point of a shapely object. |
get_shapely_object_angle |
Get the border point at a given angle. |
get_shapely_object_bbox |
Get the bounding box of a shapely object. |
get_shapely_object_border |
Get the border point in a given direction. |
get_transformation_for_frame |
Get transformation for a frame defined by origin and axes. |
invert_matrix_transformation |
Invert a matrix transformation. |
invert_rotation |
Invert a rotation. |
invert_scaling |
Invert a scaling. |
invert_translation |
Invert a translation. |
is_angle_between |
Check if an angle is between two angles. |
is_angle_in_sector |
Check if an angle is within a sector. |
line_has_point |
Check if a point lies on a line. |
reverse_bezier_curve |
Reverse a Bezier curve. |
reverse_elliptical_arc |
Reverse an elliptical arc. |
reverse_line |
Reverse a line (swap endpoints). |
reverse_point |
Return a copy of the point (points are directionless). |
reverse_segment |
Reverse a segment (swap endpoints). |
segment_has_point |
Check if a point lies on a segment. |
shorten_bezier_curve |
Shorten a Bezier curve by a given length. |
shorten_elliptical_arc |
Shorten an elliptical arc by a given length. |
shorten_segment |
Shorten a segment by a given length. |
transform_bezier_curve |
Transform a Bezier curve. |
transform_elliptical_arc |
Transform an elliptical arc. |
transform_elliptical_arc_to_bezier_curves |
Convert an elliptical arc to Bezier curves. |
transform_line |
Transform a line. |
transform_point |
Transform a point. |
transform_segment |
Transform a segment. |
Bbox
dataclass
Bbox(position: Point, width: float, height: float)
Bases: object
Represents a bounding box.
Attributes:
| Name | Type | Description |
|---|---|---|
position |
Point
|
Center point. |
width |
float
|
Width of the box. |
height |
float
|
Height of the box. |
Examples:
Methods:
| Name | Description |
|---|---|
anchor_point |
Get a named anchor point. |
center |
Get the center point. |
east |
Get the east (right center) point. |
east_north_east |
Get the east-north-east point. |
east_south_east |
Get the east-south-east point. |
from_bounds |
Create a Bbox from shapely bounds. |
isnan |
Check if the position has NaN coordinates. |
north |
Get the north (top center) point. |
north_east |
Get the north-east corner. |
north_north_east |
Get the north-north-east point. |
north_north_west |
Get the north-north-west point. |
north_west |
Get the north-west corner. |
size |
Get the size as (width, height). |
south |
Get the south (bottom center) point. |
south_east |
Get the south-east corner. |
south_south_east |
Get the south-south-east point. |
south_south_west |
Get the south-south-west point. |
south_west |
Get the south-west corner. |
west |
Get the west (left center) point. |
west_north_west |
Get the west-north-west point. |
west_south_west |
Get the west-south-west point. |
anchor_point
anchor_point(anchor_point: str) -> Point
Get a named anchor point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
anchor_point
|
str
|
Name like 'north', 'south_east', 'center', etc. |
required |
Returns:
| Type | Description |
|---|---|
Point
|
The anchor point. |
center
center() -> Point
east
east() -> Point
east_north_east
east_north_east() -> Point
east_south_east
east_south_east() -> Point
from_bounds
classmethod
Create a Bbox from shapely bounds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bounds
|
tuple[float, float, float, float]
|
Tuple of (min_x, min_y, max_x, max_y). |
required |
Returns:
| Type | Description |
|---|---|
|
A new Bbox. |
Source code in src/momapy/geometry.py
isnan
Check if the position has NaN coordinates.
Returns:
| Type | Description |
|---|---|
bool
|
True if position has NaN. |
north
north() -> Point
north_east
north_east() -> Point
north_north_east
north_north_east() -> Point
north_north_west
north_north_west() -> Point
north_west
north_west() -> Point
size
Get the size as (width, height).
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
Tuple of (width, height). |
south
south() -> Point
south_east
south_east() -> Point
south_south_east
south_south_east() -> Point
south_south_west
south_south_west() -> Point
south_west
south_west() -> Point
west
west() -> Point
west_north_west
west_north_west() -> Point
west_south_west
west_south_west() -> Point
BezierCurve
dataclass
Bases: GeometryObject
Represents a cubic Bezier curve.
Attributes:
| Name | Type | Description |
|---|---|---|
p1 |
Point
|
Start point. |
p2 |
Point
|
End point. |
control_points |
tuple[Point, ...]
|
Tuple of control points (1 for quadratic, 2 for cubic). |
Examples:
Methods:
| Name | Description |
|---|---|
bbox |
Get the bounding box of the curve. |
evaluate |
Evaluate the curve at parameter s. |
evaluate_multi |
Evaluate the curve at multiple parameters. |
get_angle_at_fraction |
Get angle at a fraction along the curve. |
get_intersection_with_line |
Get intersection with a line. |
get_position_and_angle_at_fraction |
Get both position and angle at a fraction. |
get_position_at_fraction |
Get point at a fraction along the curve. |
length |
Calculate the length of the curve. |
reversed |
Return a reversed copy of the curve. |
shortened |
Return a shortened copy of the curve. |
to_shapely |
Convert to a shapely LineString. |
transformed |
Apply a transformation to this curve. |
bbox
evaluate
evaluate(s: float) -> Point
Evaluate the curve at parameter s.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s
|
float
|
Parameter value from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
Point
|
The point at parameter s. |
Source code in src/momapy/geometry.py
evaluate_multi
evaluate_multi(s: ndarray) -> list[Point]
Evaluate the curve at multiple parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
s
|
ndarray
|
Array of parameter values. |
required |
Returns:
| Type | Description |
|---|---|
list[Point]
|
List of points. |
Source code in src/momapy/geometry.py
get_angle_at_fraction
Get angle at a fraction along the curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
|
Angle in radians. |
Source code in src/momapy/geometry.py
get_intersection_with_line
get_position_and_angle_at_fraction
Get both position and angle at a fraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
|
Tuple of (point, angle). |
Source code in src/momapy/geometry.py
get_position_at_fraction
Get point at a fraction along the curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
|
The point at that fraction. |
Source code in src/momapy/geometry.py
length
reversed
Return a reversed copy of the curve.
Returns:
| Type | Description |
|---|---|
|
A new BezierCurve going in reverse direction. |
shortened
shortened(length: float, start_or_end: Literal['start', 'end'] = 'end') -> BezierCurve
Return a shortened copy of the curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
float
|
Amount to shorten by. |
required |
start_or_end
|
Literal['start', 'end']
|
Which end to shorten from. |
'end'
|
Returns:
| Type | Description |
|---|---|
BezierCurve
|
A new shortened BezierCurve. |
Source code in src/momapy/geometry.py
to_shapely
Convert to a shapely LineString.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_segs
|
Number of segments to approximate with. |
50
|
Returns:
| Type | Description |
|---|---|
|
A shapely LineString. |
Source code in src/momapy/geometry.py
transformed
Apply a transformation to this curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transformation
|
The transformation to apply. |
required |
Returns:
| Type | Description |
|---|---|
|
A new transformed BezierCurve. |
Source code in src/momapy/geometry.py
EllipticalArc
dataclass
EllipticalArc(p1: Point, p2: Point, rx: float, ry: float, x_axis_rotation: float, arc_flag: int, sweep_flag: int)
Bases: GeometryObject
Represents an elliptical arc.
Attributes:
| Name | Type | Description |
|---|---|---|
p1 |
Point
|
Start point. |
p2 |
Point
|
End point. |
rx |
float
|
X-radius of the ellipse. |
ry |
float
|
Y-radius of the ellipse. |
x_axis_rotation |
float
|
Rotation of the x-axis in radians. |
arc_flag |
int
|
Large arc flag (0 or 1). |
sweep_flag |
int
|
Sweep flag (0 or 1). |
Examples:
Methods:
| Name | Description |
|---|---|
bbox |
Get the bounding box of the arc. |
get_angle_at_fraction |
Get angle at a fraction along the arc. |
get_center |
Get the center point of the ellipse. |
get_center_parameterization |
Get the center parameterization of the arc. |
get_intersection_with_line |
Get intersection with a line. |
get_position_and_angle_at_fraction |
Get both position and angle at a fraction. |
get_position_at_fraction |
Get point at a fraction along the arc. |
length |
Calculate the length of the arc. |
reversed |
Return a reversed copy of the arc. |
shortened |
Return a shortened copy of the arc. |
to_bezier_curves |
Convert to Bezier curves. |
to_shapely |
Convert to a shapely LineString. |
transformed |
Apply a transformation to this arc. |
bbox
bbox() -> Bbox
get_angle_at_fraction
Get angle at a fraction along the arc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Angle in radians. |
Source code in src/momapy/geometry.py
get_center
get_center() -> Point
get_center_parameterization
Get the center parameterization of the arc.
Returns:
| Type | Description |
|---|---|
tuple[float, float, float, float, float, float, float, float]
|
Tuple of (cx, cy, rx, ry, sigma, theta1, theta2, delta_theta). |
Source code in src/momapy/geometry.py
get_intersection_with_line
get_position_and_angle_at_fraction
get_position_and_angle_at_fraction(fraction: float) -> tuple[Point, float]
Get both position and angle at a fraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Point, float]
|
Tuple of (point, angle). |
Source code in src/momapy/geometry.py
get_position_at_fraction
get_position_at_fraction(fraction: float) -> Point
Get point at a fraction along the arc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
Point
|
The point at that fraction. |
Source code in src/momapy/geometry.py
length
reversed
reversed() -> EllipticalArc
Return a reversed copy of the arc.
Returns:
| Type | Description |
|---|---|
EllipticalArc
|
A new EllipticalArc going in reverse direction. |
shortened
shortened(length: float, start_or_end: Literal['start', 'end'] = 'end') -> EllipticalArc
Return a shortened copy of the arc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
float
|
Amount to shorten by. |
required |
start_or_end
|
Literal['start', 'end']
|
Which end to shorten from. |
'end'
|
Returns:
| Type | Description |
|---|---|
EllipticalArc
|
A new shortened EllipticalArc. |
Source code in src/momapy/geometry.py
to_bezier_curves
to_bezier_curves() -> BezierCurve
Convert to Bezier curves.
Returns:
| Type | Description |
|---|---|
BezierCurve
|
BezierCurve(s) approximating the arc. |
to_shapely
Convert to a shapely LineString.
Returns:
| Type | Description |
|---|---|
|
A shapely LineString approximating the arc. |
Source code in src/momapy/geometry.py
transformed
transformed(transformation: Transformation) -> EllipticalArc
Apply a transformation to this arc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transformation
|
Transformation
|
The transformation to apply. |
required |
Returns:
| Type | Description |
|---|---|
EllipticalArc
|
A new transformed EllipticalArc. |
Source code in src/momapy/geometry.py
GeometryObject
dataclass
Bases: ABC
Abstract base class for all geometry objects.
Methods:
| Name | Description |
|---|---|
to_shapely |
Convert to a shapely geometry object. |
to_shapely
abstractmethod
Convert to a shapely geometry object.
Returns:
| Type | Description |
|---|---|
Geometry
|
A shapely geometry representing this object. |
Line
dataclass
Bases: GeometryObject
Represents an infinite line defined by two points.
Attributes:
| Name | Type | Description |
|---|---|---|
p1 |
Point
|
First point on the line. |
p2 |
Point
|
Second point on the line. |
Examples:
Methods:
| Name | Description |
|---|---|
get_angle_to_horizontal |
Get the angle of the line relative to horizontal. |
get_distance_to_point |
Get perpendicular distance from a point to this line. |
get_intersection_with_line |
Get intersection with another line. |
has_point |
Check if a point lies on this line. |
intercept |
Calculate the y-intercept of the line. |
is_coincident_to_line |
Check if this line is coincident with another. |
is_parallel_to_line |
Check if this line is parallel to another. |
reversed |
Return a reversed copy of the line. |
slope |
Calculate the slope of the line. |
to_shapely |
Convert to a shapely LineString. |
transformed |
Apply a transformation to this line. |
get_angle_to_horizontal
Get the angle of the line relative to horizontal.
Returns:
| Type | Description |
|---|---|
float
|
Angle in radians. |
get_distance_to_point
get_distance_to_point(point: Point) -> float
Get perpendicular distance from a point to this line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Point
|
The point to measure from. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The perpendicular distance. |
Source code in src/momapy/geometry.py
get_intersection_with_line
has_point
has_point(point: Point, max_distance: float = 0.01) -> bool
Check if a point lies on this line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Point
|
The point to check. |
required |
max_distance
|
float
|
Maximum allowed distance from line. |
0.01
|
Returns:
| Type | Description |
|---|---|
bool
|
True if point is on the line within tolerance. |
Source code in src/momapy/geometry.py
intercept
Calculate the y-intercept of the line.
Returns:
| Type | Description |
|---|---|
float
|
The y-intercept, or NaN if vertical. |
Source code in src/momapy/geometry.py
is_coincident_to_line
is_coincident_to_line(line: Line) -> bool
Check if this line is coincident with another.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
Line
|
The other line. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if coincident (same infinite line). |
Source code in src/momapy/geometry.py
is_parallel_to_line
is_parallel_to_line(line: Line) -> bool
Check if this line is parallel to another.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
Line
|
The other line. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if parallel. |
reversed
reversed() -> Line
Return a reversed copy of the line.
Returns:
| Type | Description |
|---|---|
Line
|
A new Line with p1 and p2 swapped. |
slope
Calculate the slope of the line.
Returns:
| Type | Description |
|---|---|
float
|
The slope, or NaN if vertical. |
to_shapely
Convert to a shapely LineString.
Returns:
| Type | Description |
|---|---|
LineString
|
A shapely LineString. |
transformed
transformed(transformation: Transformation) -> Line
Apply a transformation to this line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transformation
|
Transformation
|
The transformation to apply. |
required |
Returns:
| Type | Description |
|---|---|
Line
|
A new transformed Line. |
Source code in src/momapy/geometry.py
MatrixTransformation
dataclass
Bases: Transformation
Represents a transformation as a 3x3 matrix.
Attributes:
| Name | Type | Description |
|---|---|---|
m |
NDArray
|
The 3x3 transformation matrix. |
Methods:
| Name | Description |
|---|---|
inverted |
Get the inverse transformation. |
to_matrix |
Get the matrix representation. |
inverted
inverted() -> Transformation
Get the inverse transformation.
Returns:
| Type | Description |
|---|---|
Transformation
|
The inverse matrix transformation. |
to_matrix
Point
dataclass
Bases: GeometryObject
Represents a 2D point with x and y coordinates.
Attributes:
| Name | Type | Description |
|---|---|---|
x |
float
|
The x-coordinate. |
y |
float
|
The y-coordinate. |
Examples:
Methods:
| Name | Description |
|---|---|
bbox |
Get the bounding box of this point. |
from_fortranarray |
Create a Point from a numpy Fortran array. |
from_shapely |
Create a Point from a shapely Point. |
from_tuple |
Create a Point from a tuple. |
get_angle_to_horizontal |
Get the angle from origin to this point relative to horizontal. |
get_intersection_with_line |
Get intersection points with a line. |
isnan |
Check if either coordinate is NaN. |
reversed |
Return a reversed copy (identity for points). |
round |
Round coordinates to specified digits. |
to_fortranarray |
Convert to a numpy Fortran array. |
to_matrix |
Convert to a 3x1 numpy matrix for transformation operations. |
to_shapely |
Convert to a shapely Point. |
to_tuple |
Convert to a tuple. |
transformed |
Apply a transformation to this point. |
bbox
bbox() -> Bbox
Get the bounding box of this point.
Returns:
| Type | Description |
|---|---|
Bbox
|
A Bbox with zero width and height. |
from_fortranarray
classmethod
Create a Point from a numpy Fortran array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fortranarray
|
Any
|
A 2x1 array [[x], [y]]. |
required |
Returns:
| Type | Description |
|---|---|
Self
|
A new Point. |
Source code in src/momapy/geometry.py
from_shapely
classmethod
Create a Point from a shapely Point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Point
|
A shapely Point. |
required |
Returns:
| Type | Description |
|---|---|
Self
|
A new Point. |
Source code in src/momapy/geometry.py
from_tuple
classmethod
Create a Point from a tuple.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
tuple[float, float]
|
Tuple (x, y). |
required |
Returns:
| Type | Description |
|---|---|
Self
|
A new Point. |
get_angle_to_horizontal
Get the angle from origin to this point relative to horizontal.
Returns:
| Type | Description |
|---|---|
float
|
Angle in radians. |
get_intersection_with_line
isnan
Check if either coordinate is NaN.
Returns:
| Type | Description |
|---|---|
bool
|
True if x or y is NaN. |
reversed
reversed() -> Point
round
Round coordinates to specified digits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ndigits
|
Number of decimal places. |
None
|
Returns:
| Type | Description |
|---|---|
|
A new Point with rounded coordinates. |
Source code in src/momapy/geometry.py
to_fortranarray
Convert to a numpy Fortran array.
Returns:
| Type | Description |
|---|---|
Any
|
A 2x1 Fortran array [[x], [y]]. |
to_matrix
Convert to a 3x1 numpy matrix for transformation operations.
Returns:
| Type | Description |
|---|---|
ndarray
|
A numpy array [[x], [y], [1]]. |
to_shapely
to_tuple
transformed
transformed(transformation: Transformation) -> Point
Apply a transformation to this point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transformation
|
Transformation
|
The transformation to apply. |
required |
Returns:
| Type | Description |
|---|---|
Point
|
A new transformed Point. |
Source code in src/momapy/geometry.py
Rotation
dataclass
Rotation(angle: float, point: Point | None = None)
Bases: Transformation
Represents a rotation transformation.
Attributes:
| Name | Type | Description |
|---|---|---|
angle |
float
|
Rotation angle in radians. |
point |
Point | None
|
Optional center of rotation (defaults to origin). |
Examples:
Methods:
| Name | Description |
|---|---|
inverted |
Get the inverse rotation. |
to_matrix |
Convert to a rotation matrix. |
inverted
inverted() -> Transformation
Get the inverse rotation.
Returns:
| Type | Description |
|---|---|
Transformation
|
A rotation by the negative angle. |
to_matrix
Convert to a rotation matrix.
Returns:
| Type | Description |
|---|---|
NDArray
|
A 3x3 rotation matrix. |
Source code in src/momapy/geometry.py
Scaling
dataclass
Bases: Transformation
Represents a scaling transformation.
Attributes:
| Name | Type | Description |
|---|---|---|
sx |
float
|
Scale factor in x direction. |
sy |
float
|
Scale factor in y direction. |
Examples:
Methods:
| Name | Description |
|---|---|
inverted |
Get the inverse scaling. |
to_matrix |
Convert to a scaling matrix. |
inverted
inverted() -> Transformation
to_matrix
Convert to a scaling matrix.
Returns:
| Type | Description |
|---|---|
NDArray
|
A 3x3 scaling matrix. |
Source code in src/momapy/geometry.py
Segment
dataclass
Bases: GeometryObject
Represents a line segment between two points.
Attributes:
| Name | Type | Description |
|---|---|---|
p1 |
Point
|
Start point. |
p2 |
Point
|
End point. |
Examples:
Methods:
| Name | Description |
|---|---|
bbox |
Get the bounding box of the segment. |
from_shapely |
Create a Segment from a shapely LineString. |
get_angle_at_fraction |
Get angle at a fraction along the segment. |
get_angle_to_horizontal |
Get the angle of the segment relative to horizontal. |
get_distance_to_point |
Get shortest distance from a point to this segment. |
get_intersection_with_line |
Get intersection with a line. |
get_position_and_angle_at_fraction |
Get both position and angle at a fraction. |
get_position_at_fraction |
Get point at a fraction along the segment. |
has_point |
Check if a point lies on this segment. |
length |
Calculate the length of the segment. |
reversed |
Return a reversed copy of the segment. |
shortened |
Return a shortened copy of the segment. |
to_shapely |
Convert to a shapely LineString. |
transformed |
Apply a transformation to this segment. |
bbox
bbox() -> Bbox
from_shapely
classmethod
Create a Segment from a shapely LineString.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line_string
|
LineString
|
A 2-point LineString. |
required |
Returns:
| Type | Description |
|---|---|
Self
|
A new Segment. |
Source code in src/momapy/geometry.py
get_angle_at_fraction
Get angle at a fraction along the segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Angle in radians. |
Source code in src/momapy/geometry.py
get_angle_to_horizontal
Get the angle of the segment relative to horizontal.
Returns:
| Type | Description |
|---|---|
float
|
Angle in radians. |
get_distance_to_point
get_distance_to_point(point: Point) -> float
Get shortest distance from a point to this segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Point
|
The point to measure from. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The shortest distance. |
Source code in src/momapy/geometry.py
get_intersection_with_line
get_position_and_angle_at_fraction
get_position_and_angle_at_fraction(fraction: float) -> tuple[Point, float]
Get both position and angle at a fraction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Point, float]
|
Tuple of (point, angle in radians). |
Source code in src/momapy/geometry.py
get_position_at_fraction
get_position_at_fraction(fraction: float) -> Point
Get point at a fraction along the segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fraction
|
float
|
Fraction from 0 to 1 (0 = start, 1 = end). |
required |
Returns:
| Type | Description |
|---|---|
Point
|
The point at that fraction. |
Source code in src/momapy/geometry.py
has_point
has_point(point: Point, max_distance: float = 0.01) -> bool
Check if a point lies on this segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Point
|
The point to check. |
required |
max_distance
|
float
|
Maximum allowed distance. |
0.01
|
Returns:
| Type | Description |
|---|---|
bool
|
True if point is on the segment within tolerance. |
Source code in src/momapy/geometry.py
length
Calculate the length of the segment.
Returns:
| Type | Description |
|---|---|
float
|
The Euclidean length. |
reversed
reversed() -> Segment
Return a reversed copy of the segment.
Returns:
| Type | Description |
|---|---|
Segment
|
A new Segment with p1 and p2 swapped. |
shortened
shortened(length: float, start_or_end: Literal['start', 'end'] = 'end') -> Segment
Return a shortened copy of the segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
float
|
Amount to shorten by. |
required |
start_or_end
|
Literal['start', 'end']
|
Which end to shorten from. |
'end'
|
Returns:
| Type | Description |
|---|---|
Segment
|
A new shortened Segment. |
Source code in src/momapy/geometry.py
to_shapely
Convert to a shapely LineString.
Returns:
| Type | Description |
|---|---|
LineString
|
A shapely LineString. |
transformed
transformed(transformation: Transformation) -> Segment
Apply a transformation to this segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
transformation
|
Transformation
|
The transformation to apply. |
required |
Returns:
| Type | Description |
|---|---|
Segment
|
A new transformed Segment. |
Source code in src/momapy/geometry.py
Transformation
dataclass
Bases: ABC
Abstract base class for geometric transformations.
Methods:
| Name | Description |
|---|---|
inverted |
Get the inverse transformation. |
to_matrix |
Convert to a 3x3 transformation matrix. |
inverted
abstractmethod
inverted() -> Transformation
Get the inverse transformation.
Returns:
| Type | Description |
|---|---|
Transformation
|
The inverse transformation. |
to_matrix
abstractmethod
Convert to a 3x3 transformation matrix.
Returns:
| Type | Description |
|---|---|
NDArray
|
A 3x3 numpy array. |
Translation
dataclass
Bases: Transformation
Represents a translation transformation.
Attributes:
| Name | Type | Description |
|---|---|---|
tx |
float
|
Translation in x direction. |
ty |
float
|
Translation in y direction. |
Examples:
Methods:
| Name | Description |
|---|---|
inverted |
Get the inverse translation. |
to_matrix |
Convert to a translation matrix. |
inverted
inverted() -> Transformation
to_matrix
Convert to a translation matrix.
Returns:
| Type | Description |
|---|---|
NDArray
|
A 3x3 translation matrix. |
are_lines_coincident
Check if two lines are coincident.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line1
|
Line
|
First line. |
required |
line2
|
Line
|
Second line. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if coincident. |
Source code in src/momapy/geometry.py
are_lines_parallel
get_angle_at_fraction_of_bezier_curve
get_angle_at_fraction_of_bezier_curve(bezier_curve: BezierCurve, fraction: float) -> float
Get angle at a fraction along a Bezier curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bezier_curve
|
BezierCurve
|
The curve. |
required |
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Angle in radians. |
Source code in src/momapy/geometry.py
get_angle_at_fraction_of_elliptical_arc
get_angle_at_fraction_of_elliptical_arc(elliptical_arc: EllipticalArc, fraction: float) -> float
Get angle at a fraction along an elliptical arc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elliptical_arc
|
EllipticalArc
|
The arc. |
required |
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Angle in radians. |
Source code in src/momapy/geometry.py
get_angle_at_fraction_of_segment
get_angle_at_fraction_of_segment(segment: Segment, fraction: float) -> float
Get angle at a fraction along a segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
segment
|
Segment
|
The segment. |
required |
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Angle in radians. |
Source code in src/momapy/geometry.py
get_angle_between_segments
Get angle between two segments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
segment1
|
Segment
|
First segment. |
required |
segment2
|
Segment
|
Second segment. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Angle in radians (range -pi to pi). |
Source code in src/momapy/geometry.py
get_angle_to_horizontal_of_line
Get angle of a line relative to horizontal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
Line | Segment
|
A Line or Segment. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Angle in radians. |
Source code in src/momapy/geometry.py
get_angle_to_horizontal_of_point
get_angle_to_horizontal_of_point(point: Point) -> float
Get angle from origin to point relative to horizontal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Point
|
The point. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Angle in radians. |
Source code in src/momapy/geometry.py
get_center_of_elliptical_arc
get_center_of_elliptical_arc(elliptical_arc: EllipticalArc) -> Point
Get center of an elliptical arc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elliptical_arc
|
EllipticalArc
|
The arc. |
required |
Returns:
| Type | Description |
|---|---|
Point
|
The center point. |
Source code in src/momapy/geometry.py
get_center_parameterization_of_elliptical_arc
get_center_parameterization_of_elliptical_arc(elliptical_arc: EllipticalArc) -> tuple[float, float, float, float, float, float, float, float]
Get center parameterization of an elliptical arc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elliptical_arc
|
EllipticalArc
|
The arc. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float, float, float, float, float, float, float]
|
Tuple of (cx, cy, rx, ry, sigma, theta1, theta2, delta_theta). |
Source code in src/momapy/geometry.py
get_distance_between_line_and_point
Get perpendicular distance from a point to a line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
Line
|
The line. |
required |
point
|
Point
|
The point. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The perpendicular distance. |
Source code in src/momapy/geometry.py
get_distance_between_points
get_distance_between_segment_and_point
Get shortest distance from a point to a segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
segment
|
Segment
|
The segment. |
required |
point
|
Point
|
The point. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The shortest distance. |
Source code in src/momapy/geometry.py
get_intersection_of_line_and_bezier_curve
get_intersection_of_line_and_bezier_curve(line: Line, bezier_curve: BezierCurve) -> list[Point] | list[Segment]
Get intersection of a line and a Bezier curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
Line
|
The line. |
required |
bezier_curve
|
BezierCurve
|
The Bezier curve. |
required |
Returns:
| Type | Description |
|---|---|
list[Point] | list[Segment]
|
List of intersection points or segments. |
Source code in src/momapy/geometry.py
get_intersection_of_line_and_elliptical_arc
get_intersection_of_line_and_elliptical_arc(line: Line, elliptical_arc: EllipticalArc) -> list[Point] | list[Segment]
Get intersection of a line and an elliptical arc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
Line
|
The line. |
required |
elliptical_arc
|
EllipticalArc
|
The elliptical arc. |
required |
Returns:
| Type | Description |
|---|---|
list[Point] | list[Segment]
|
List of intersection points or segments. |
Source code in src/momapy/geometry.py
get_intersection_of_line_and_point
get_intersection_of_line_and_segment
get_intersection_of_line_and_segment(line: Line, segment: Segment) -> list[Point] | list[Segment] | list[Line]
Get intersection of a line and a segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
Line
|
The line. |
required |
segment
|
Segment
|
The segment. |
required |
Returns:
| Type | Description |
|---|---|
list[Point] | list[Segment] | list[Line]
|
List of intersection points, segment if coincident, or empty. |
Source code in src/momapy/geometry.py
get_intersection_of_line_and_shapely_object
get_intersection_of_line_and_shapely_object(line: Line, shapely_object: Geometry) -> list[Point] | list[Segment]
Get intersection of a line with a shapely object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
Line
|
The line. |
required |
shapely_object
|
Geometry
|
A shapely geometry. |
required |
Returns:
| Type | Description |
|---|---|
list[Point] | list[Segment]
|
List of intersection points or segments. |
Source code in src/momapy/geometry.py
get_intersection_of_lines
Get intersection of two lines.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line1
|
Line
|
First line. |
required |
line2
|
Line
|
Second line. |
required |
Returns:
| Type | Description |
|---|---|
list[Line] | list[Point]
|
List containing intersection point(s) or coincident line. |
Source code in src/momapy/geometry.py
get_normalized_angle
Normalize an angle to [0, 2*pi).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle
|
float
|
Angle in radians. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Normalized angle. |
get_position_and_angle_at_fraction_of_bezier_curve
get_position_and_angle_at_fraction_of_bezier_curve(bezier_curve: BezierCurve, fraction: float) -> tuple[Point, float]
Get position and angle at a fraction along a Bezier curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bezier_curve
|
BezierCurve
|
The curve. |
required |
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Point, float]
|
Tuple of (point, angle). |
Source code in src/momapy/geometry.py
get_position_and_angle_at_fraction_of_elliptical_arc
get_position_and_angle_at_fraction_of_elliptical_arc(elliptical_arc: EllipticalArc, fraction: float) -> tuple[Point, float]
Get position and angle at a fraction along an elliptical arc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elliptical_arc
|
EllipticalArc
|
The arc. |
required |
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Point, float]
|
Tuple of (point, angle). |
Source code in src/momapy/geometry.py
get_position_and_angle_at_fraction_of_segment
get_position_and_angle_at_fraction_of_segment(segment: Segment, fraction: float) -> tuple[Point, float]
Get position and angle at a fraction along a segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
segment
|
Segment
|
The segment. |
required |
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
tuple[Point, float]
|
Tuple of (point, angle). |
Source code in src/momapy/geometry.py
get_position_at_fraction_of_bezier_curve
get_position_at_fraction_of_bezier_curve(bezier_curve: BezierCurve, fraction: float) -> Point
Get point at a fraction along a Bezier curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bezier_curve
|
BezierCurve
|
The curve. |
required |
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
Point
|
The point at that fraction. |
Source code in src/momapy/geometry.py
get_position_at_fraction_of_elliptical_arc
get_position_at_fraction_of_elliptical_arc(elliptical_arc: EllipticalArc, fraction: float) -> Point
Get point at a fraction along an elliptical arc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elliptical_arc
|
EllipticalArc
|
The arc. |
required |
fraction
|
float
|
Fraction from 0 to 1. |
required |
Returns:
| Type | Description |
|---|---|
Point
|
The point at that fraction. |
Source code in src/momapy/geometry.py
get_position_at_fraction_of_segment
get_shapely_object_anchor_point
get_shapely_object_anchor_point(shapely_object: Geometry, anchor_point: str, center: Point | None = None) -> Point
Get an anchor point of a shapely object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shapely_object
|
Geometry
|
A shapely geometry. |
required |
anchor_point
|
str
|
Name of anchor point. |
required |
center
|
Point | None
|
Optional center point. |
None
|
Returns:
| Type | Description |
|---|---|
Point
|
The anchor point. |
Source code in src/momapy/geometry.py
get_shapely_object_angle
get_shapely_object_angle(shapely_object: Geometry, angle: float, unit: Literal['degrees', 'radians'] = 'degrees', center: Point | None = None) -> Point | None
Get the border point at a given angle.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shapely_object
|
Geometry
|
A shapely geometry. |
required |
angle
|
float
|
The angle. |
required |
unit
|
Literal['degrees', 'radians']
|
Unit of angle ('degrees' or 'radians'). |
'degrees'
|
center
|
Point | None
|
Optional center point. |
None
|
Returns:
| Type | Description |
|---|---|
Point | None
|
The border point or None. |
Source code in src/momapy/geometry.py
get_shapely_object_bbox
get_shapely_object_bbox(shapely_object: Geometry) -> Bbox
Get the bounding box of a shapely object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shapely_object
|
Geometry
|
A shapely geometry. |
required |
Returns:
| Type | Description |
|---|---|
Bbox
|
The bounding box. |
Source code in src/momapy/geometry.py
get_shapely_object_border
get_shapely_object_border(shapely_object: Geometry, point: Point, center: Point | None = None) -> Point | None
Get the border point in a given direction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
shapely_object
|
Geometry
|
A shapely geometry. |
required |
point
|
Point
|
Direction point. |
required |
center
|
Point | None
|
Optional center point. |
None
|
Returns:
| Type | Description |
|---|---|
Point | None
|
The border point or None. |
Source code in src/momapy/geometry.py
get_transformation_for_frame
get_transformation_for_frame(origin: Point, unit_x: Point, unit_y: Point) -> MatrixTransformation
Get transformation for a frame defined by origin and axes.
Given a frame F defined by its origin, unit x axis vector, and unit y axis vector, returns the transformation that converts points from F coordinates to reference frame coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
origin
|
Point
|
Origin of the frame. |
required |
unit_x
|
Point
|
Unit x-axis vector. |
required |
unit_y
|
Point
|
Unit y-axis vector. |
required |
Returns:
| Type | Description |
|---|---|
MatrixTransformation
|
The transformation matrix. |
Source code in src/momapy/geometry.py
invert_matrix_transformation
invert_matrix_transformation(matrix_transformation: MatrixTransformation) -> MatrixTransformation
Invert a matrix transformation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
matrix_transformation
|
MatrixTransformation
|
The transformation to invert. |
required |
Returns:
| Type | Description |
|---|---|
MatrixTransformation
|
The inverse transformation. |
Source code in src/momapy/geometry.py
invert_rotation
invert_scaling
invert_translation
invert_translation(translation: Translation) -> Translation
Invert a translation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
translation
|
Translation
|
The translation to invert. |
required |
Returns:
| Type | Description |
|---|---|
Translation
|
A translation by (-tx, -ty). |
Source code in src/momapy/geometry.py
is_angle_between
Check if an angle is between two angles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle
|
float
|
The angle to check (radians). |
required |
start_angle
|
float
|
Start angle (radians). |
required |
end_angle
|
float
|
End angle (radians). |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if angle is between start and end. |
Source code in src/momapy/geometry.py
is_angle_in_sector
Check if an angle is within a sector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
angle
|
float
|
The angle to check (radians). |
required |
center
|
Point
|
Center of sector. |
required |
point1
|
Point
|
First sector boundary. |
required |
point2
|
Point
|
Second sector boundary. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if angle is in sector. |
Source code in src/momapy/geometry.py
line_has_point
Check if a point lies on a line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
Line
|
The line. |
required |
point
|
Point
|
The point. |
required |
max_distance
|
float
|
Maximum allowed distance. |
0.01
|
Returns:
| Type | Description |
|---|---|
bool
|
True if point is on the line within tolerance. |
Source code in src/momapy/geometry.py
reverse_bezier_curve
reverse_bezier_curve(bezier_curve: BezierCurve) -> BezierCurve
Reverse a Bezier curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bezier_curve
|
BezierCurve
|
The curve to reverse. |
required |
Returns:
| Type | Description |
|---|---|
BezierCurve
|
A new BezierCurve going in reverse direction. |
Source code in src/momapy/geometry.py
reverse_elliptical_arc
reverse_elliptical_arc(elliptical_arc: EllipticalArc) -> EllipticalArc
Reverse an elliptical arc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elliptical_arc
|
EllipticalArc
|
The arc to reverse. |
required |
Returns:
| Type | Description |
|---|---|
EllipticalArc
|
A new EllipticalArc going in reverse direction. |
Source code in src/momapy/geometry.py
reverse_line
reverse_point
reverse_segment
Reverse a segment (swap endpoints).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
segment
|
The segment to reverse. |
required |
Returns:
| Type | Description |
|---|---|
|
A new Segment with p1 and p2 swapped. |
segment_has_point
Check if a point lies on a segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
segment
|
Segment
|
The segment. |
required |
point
|
Point
|
The point. |
required |
max_distance
|
float
|
Maximum allowed distance. |
0.01
|
Returns:
| Type | Description |
|---|---|
bool
|
True if point is on the segment within tolerance. |
Source code in src/momapy/geometry.py
shorten_bezier_curve
shorten_bezier_curve(bezier_curve: BezierCurve, length: float, start_or_end: Literal['start', 'end'] = 'end') -> BezierCurve
Shorten a Bezier curve by a given length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bezier_curve
|
BezierCurve
|
The curve to shorten. |
required |
length
|
float
|
Amount to shorten by. |
required |
start_or_end
|
Literal['start', 'end']
|
Which end to shorten from. |
'end'
|
Returns:
| Type | Description |
|---|---|
BezierCurve
|
A new shortened BezierCurve. |
Source code in src/momapy/geometry.py
shorten_elliptical_arc
shorten_elliptical_arc(elliptical_arc: EllipticalArc, length: float, start_or_end: Literal['start', 'end'] = 'end')
Shorten an elliptical arc by a given length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elliptical_arc
|
EllipticalArc
|
The arc to shorten. |
required |
length
|
float
|
Amount to shorten by. |
required |
start_or_end
|
Literal['start', 'end']
|
Which end to shorten from. |
'end'
|
Returns:
| Type | Description |
|---|---|
|
A new shortened EllipticalArc. |
Source code in src/momapy/geometry.py
shorten_segment
shorten_segment(segment: Segment, length: float, start_or_end: Literal['start', 'end'] = 'end') -> Segment
Shorten a segment by a given length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
segment
|
Segment
|
The segment to shorten. |
required |
length
|
float
|
Amount to shorten by. |
required |
start_or_end
|
Literal['start', 'end']
|
Which end to shorten from. |
'end'
|
Returns:
| Type | Description |
|---|---|
Segment
|
A new shortened Segment. |
Source code in src/momapy/geometry.py
transform_bezier_curve
transform_bezier_curve(bezier_curve: BezierCurve, transformation: Transformation) -> BezierCurve
Transform a Bezier curve.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bezier_curve
|
BezierCurve
|
The curve to transform. |
required |
transformation
|
Transformation
|
The transformation to apply. |
required |
Returns:
| Type | Description |
|---|---|
BezierCurve
|
The transformed BezierCurve. |
Source code in src/momapy/geometry.py
transform_elliptical_arc
transform_elliptical_arc(elliptical_arc: EllipticalArc, transformation: Transformation) -> EllipticalArc
Transform an elliptical arc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elliptical_arc
|
EllipticalArc
|
The arc to transform. |
required |
transformation
|
Transformation
|
The transformation to apply. |
required |
Returns:
| Type | Description |
|---|---|
EllipticalArc
|
The transformed EllipticalArc. |
Source code in src/momapy/geometry.py
transform_elliptical_arc_to_bezier_curves
transform_elliptical_arc_to_bezier_curves(elliptical_arc: EllipticalArc) -> list[BezierCurve]
Convert an elliptical arc to Bezier curves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
elliptical_arc
|
EllipticalArc
|
The arc to convert. |
required |
Returns:
| Type | Description |
|---|---|
list[BezierCurve]
|
List of BezierCurve approximating the arc. |
Source code in src/momapy/geometry.py
2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 | |
transform_line
transform_line(line: Line, transformation: Transformation) -> Line
Transform a line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
Line
|
The line to transform. |
required |
transformation
|
Transformation
|
The transformation to apply. |
required |
Returns:
| Type | Description |
|---|---|
Line
|
The transformed line. |
Source code in src/momapy/geometry.py
transform_point
transform_point(point: Point, transformation: Transformation) -> Point
Transform a point.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
Point
|
The point to transform. |
required |
transformation
|
Transformation
|
The transformation to apply. |
required |
Returns:
| Type | Description |
|---|---|
Point
|
The transformed point. |
Source code in src/momapy/geometry.py
transform_segment
transform_segment(segment: Segment, transformation: Transformation) -> Segment
Transform a segment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
segment
|
Segment
|
The segment to transform. |
required |
transformation
|
Transformation
|
The transformation to apply. |
required |
Returns:
| Type | Description |
|---|---|
Segment
|
The transformed segment. |