pyxc.transform.affine2d

Module Contents

Classes

Affine2D

2-dimensional Affine transformation.

class pyxc.transform.affine2d.Affine2D(transformation_matrix: numpy.ndarray | None = None, parent: pyxc.transform.transform_base.MatrixTransformationBase | None = None)[source]

Bases: pyxc.transform.transform_base.MatrixTransformationBase

2-dimensional Affine transformation.

By calling each transformation method, such as translate(), corresponding transformation matrix is generated and queued in the transformation queue. The queued transformation entries are later compiled into a single matrix by calling the compile() method.

Parameters:
transformation_matrixnp.ndarray, optional

The transformation matrix to be used for the transformation.

parentTransformationBase, optional

The parent transformation object.

Methods

translate(tx, ty)

rotate(angle)

shear_x(angle)

shear_y(angle)

scale(x_scale, y_scale)

flip_x()

flip_y()

flip_xy()

translate(tx: float, ty: float)[source]

Transformation matrix.

Parameters:
txfloat

The amount of the translation along x direction.

tyfloat

The amount of the translation along y direction.

Returns:
np.ndarray:

Translation matrix.

See also

pyxc.transform.transform_base.TransformationCommon.queue_return_handler

Possible keyword arguments.

rotate(angle: float)[source]

Rotation matrix.

Parameters:
anglefloat

Rotation angle in radian. Note: numpy.deg2rad() is the convenient method to convert degree to radian.

Returns:
np.ndarray:

Rotation matrix.

See also

pyxc.transform.transform_base.TransformationCommon.queue_return_handler

Possible keyword arguments.

shear_x(angle: float)[source]

Shear transformation along the x-axis.

Parameters:
anglefloat

Shear angle in radian. Note: numpy.deg2rad() is the convenient method to convert degree to radian.

Returns:
np.ndarray:

Shear matrix along the x-direction.

See also

pyxc.transform.transform_base.TransformationCommon.queue_return_handler

Possible keyword arguments.

shear_y(angle: float)[source]

Shear transformation along the y-axis.

Parameters:
anglefloat

Shear angle in radian. Note: numpy.deg2rad() is the convenient method to convert degree to radian.

Returns:
np.ndarray:

Shear matrix along the x-direction.

See also

pyxc.transform.transform_base.TransformationCommon.queue_return_handler

Possible keyword arguments.

scaling(sx: float, sy: float)[source]

Scaling transformation matrix.

Parameters:
sxfloat

Scaling factor along the x-direction.

syfloat

Scaling factor along the y-direction.

Returns:
np.ndarray:

Scaling matrix along the x-direction.

See also

pyxc.transform.transform_base.TransformationCommon.queue_return_handler

Possible keyword arguments.

Notes

If sx = sy = 1, then the composed matrix is equal to the identity matrix.

flip_x()[source]

Invert by x-axis.

Returns:
np.ndarray:

Reflection matrix along the x-direction.

flip_y()[source]

Invert by y-axis.

Returns:
np.ndarray:

Reflection matrix along the y-direction.

flip_xy()[source]

Invert X- and Y-axis signs.

Returns:
np.ndarray:

Reflection matrix along the x- and y-direction.

See also

pyxc.transform.transform_base.TransformationCommon.queue_return_handler

Possible keyword arguments.

flip_x, flip_y