RAIMAD

raimad.Transform

class Transform( builtins.object, ):
Transformation: container for affine matrix.

def __init__(self) -> None:

Initialize a new Transform as an identity transform.

def reset(self) -> None:

Reset this transform to be an identity transform.

def transform_poly(self, poly: 'rai.typing.Poly') -> 'rai.typing.Poly':

Apply transformation to poly and return new transformed poly.
Parameters
polyrai.typing.Poly
The Poly to transform
Returns
rai.typing.Poly
The new, transformed, Poly

def transform_point(self, point: 'rai.typing.PointLike') -> 'rai.typing.Point':

Apply this transform to a point, and return the transformed point.
A Point (tuple of two floats) is always returned, even if a BoundPoint is passed in.
Parameters
pointrai.typing.PointLike
The point to transform.
Returns
rai.typing.Point
The transformed point.

def compose(self, transform: Self) -> Self:

Apply a different transform to this transform.
Parameters
transformSelf
The other transform to apply to this one
Returns
Self
This transform is returned to allow method chaining.

def get_translation(self) -> tuple[float, float]:

Return how much this transform translates the coordinate plane.
Returns
tuple[float, float]
The first item is how much the plane is moved along the x axis. The second item is how much the plane is moved along the y axis.

def get_rotation(self) -> float:

Return how much this transform rotates the coordinate plane.
Returns
float
The angle by which this transform rotates the coordinate plane (radians, in the positive orientation)

def get_shear(self) -> float:

Return a how much this transform shears the coordinate plane.
Returns
float
A number representing the shear.

def get_scale(self) -> tuple[float, float]:

Return how much this transform scales the x and y axis.
Returns
tuple[float, float]
The first float is the scaling factor along the x axis. The second float is the scaling factor along the y axis.

def does_translate(self) -> bool:

Check whether this transform applies a translation.
Returns
bool
True if the transform translates. False otherwise.

def does_rotate(self) -> bool:

Check whether this transform applies a rotation.
Returns
bool
True if the transform rotates. False otherwise.

def does_shear(self) -> bool:

Check whether this transform applies a shear.
Returns
bool
True if the transform shears. False otherwise.

def does_scale(self) -> bool:

Check whether this transform applies a scale.
Returns
bool
True if the transform scales. False otherwise.

def __repr__(self) -> str:

Return string representation of transform.
Returns
str
A representation of this transform.

def copy(self) -> Self:

Duplicate transform.
Returns
Self
The copied transform.

def move(self, x: float, y: float) -> Self:

Move transform.
Parameters
xfloat
Move this many units along x axis.
yfloat
Move this many units along y axis.
Returns
Self
This transform is returned to allow chaining methods.

def movex(self, x: float = 0) -> Self:

Move along x axis.
Parameters
xfloat
Move this many units along x axis.
Returns
Self
This transform is returned to allow chaining methods.

def movey(self, y: float = 0) -> Self:

Move along y axis.
Parameters
yfloat
Move this many units along y axis.
Returns
Self
This transform is returned to allow chaining methods.

def scale(self, x: float, y: float | None = None) -> Self:

Scale a transform.
Parameters
xfloat
Factor to scale by along the x axis
yfloat
Factor to scale by along the y axis. If unspecified or None, use the x scale factor.
Returns
Self
This transform is returned to allow chaining methods.

def rotate(self, angle: float, x: float = 0, y: float = 0) -> Self:

Rotate around a point.
Parameters
anglefloat
Angle to rotate by, in radians.
xfloat
Rotate around this point (x coordinate) default: origin
yfloat
Rotate around this point (y coordinate) default: origin
Returns
Self
This transform is returned to allow chaining methods.

def hflip(self, x: float = 0) -> Self:

Flip (mirror) along horizontal axis.
Parameters
xfloat
Flip around this horizontal line (y coordinate)
Returns
Self
This transform is returned to allow chaining methods.

def vflip(self, y: float = 0) -> Self:

Flip (mirror) along vertical axis.
Parameters
yfloat
Flip around this vertical line (y coordinate)
Returns
Self
This transform is returned to allow chaining methods.

def flip(self, x: float = 0, y: float = 0) -> Self:

Flip (mirror) along both horizontal and vertical axis.
Parameters
xfloat
Flip around this point (x coordinate)
yfloat
Flip around this point (y coordinate)
Returns
Self
This transform is returned to allow chaining methods.