Basic geometry functions¶
Overview¶
The geometry module provides basic geometry functions for
computing 2D transformations and distances.
The following functions are available:
Reference¶
- plotpy.mathutils.geometry.translate(tx: float, ty: float) ndarray[source]¶
Return translation matrix
- Parameters:
tx – Translation along X-axis
ty – Translation along Y-axis
- Returns:
Translation matrix
- plotpy.mathutils.geometry.scale(sx: float, sy: float) ndarray[source]¶
Return scale matrix
- Parameters:
sx – Scale along X-axis
sy – Scale along Y-axis
- Returns:
Scale matrix
- plotpy.mathutils.geometry.rotate(alpha: float) ndarray[source]¶
Return rotation matrix
- Parameters:
alpha – Rotation angle (in radians)
- Returns:
Rotation matrix
- plotpy.mathutils.geometry.colvector(x: float, y: float) ndarray[source]¶
Return vector from coordinates
- Parameters:
x – x-coordinate
y – y-coordinate
- Returns:
Vector
- plotpy.mathutils.geometry.vector_norm(xa: float, ya: float, xb: float, yb: float) float[source]¶
Return vector norm
- Parameters:
xa – x-coordinate of first point
ya – y-coordinate of first point
xb – x-coordinate of second point
yb – y-coordinate of second point
- Returns:
Norm of vector (xa, xb)–>(ya, yb)
- plotpy.mathutils.geometry.vector_projection(dv: ndarray, xa: float, ya: float, xb: float, yb: float) ndarray[source]¶
Return vector projection
- Parameters:
dv – vector to project
xa – x-coordinate of first point
ya – y-coordinate of first point
xb – x-coordinate of second point
yb – y-coordinate of second point
- Returns:
Projection of dv on vector (xa, xb)–>(ya, yb)
- plotpy.mathutils.geometry.vector_angle(dx: float, dy: float) float[source]¶
Return vector angle with X-axis
- Parameters:
dx – x-coordinate of vector
dy – y-coordinate of vector
- Returns:
Angle between vector and X-axis (in radians)
- plotpy.mathutils.geometry.compute_center(x1: float, y1: float, x2: float, y2: float) tuple[float, float][source]¶
Compute center of rectangle
- Parameters:
x1 – x-coordinate of top-left corner
y1 – y-coordinate of top-left corner
x2 – x-coordinate of bottom-right corner
y2 – y-coordinate of bottom-right corner
- Returns:
Tuple of (x, y) coordinates of center
- plotpy.mathutils.geometry.compute_rect_size(x1: float, y1: float, x2: float, y2: float) tuple[float, float][source]¶
Compute rectangle size
- Parameters:
x1 – x-coordinate of top-left corner
y1 – y-coordinate of top-left corner
x2 – x-coordinate of bottom-right corner
y2 – y-coordinate of bottom-right corner
- Returns:
Tuple of (width, height)
- plotpy.mathutils.geometry.compute_distance(x1: float, y1: float, x2: float, y2: float) float[source]¶
Compute distance between two points
- Parameters:
x1 – x-coordinate of first point
y1 – y-coordinate of first point
x2 – x-coordinate of second point
y2 – y-coordinate of second point
- Returns:
Distance between points
- plotpy.mathutils.geometry.compute_angle(x1: float, y1: float, x2: float, y2: float, reverse: bool = False) float[source]¶
Compute angle between two points
- Parameters:
x1 – x-coordinate of first point
y1 – y-coordinate of first point
x2 – x-coordinate of second point
y2 – y-coordinate of second point
reverse – If True, return the angle in the opposite direction
- Returns:
Angle between points (in degrees)