ostk.mathematics.geometry.d2.Transformation

class Transformation(
self: ostk.mathematics.geometry.d2.Transformation,
matrix: numpy.ndarray[numpy.float64[3, 3]],
)

Bases: pybind11_object

Create a 2D transformation from a 3x3 transformation matrix.

Parameters:

matrix (Matrix3d) -- The 3x3 transformation matrix in homogeneous coordinates.

Example

>>> import numpy as np
>>> matrix = numpy.eye(3)  # Identity matrix
>>> transformation = Transformation(matrix)

Methods

apply_to

Overloaded function.

get_inverse

Get the inverse transformation.

get_matrix

Get the transformation matrix.

get_type

Get the type of the transformation.

identity

Create an identity transformation (no change).

is_defined

Check if the transformation is defined.

rotation

Create a rotation transformation around the origin.

rotation_around

Create a rotation transformation around a specific point.

string_from_type

Get the string representation of a transformation type.

translation

Create a translation transformation.

type_of_matrix

Determine the transformation type from a matrix.

undefined

Create an undefined transformation.

class Type(self: ostk.mathematics.geometry.d2.Transformation.Type, value: int)

Bases: pybind11_object

Members:

Undefined

Identity

Translation

Rotation

Scaling

Reflection

Shear

Affine

property name
apply_to(*args, **kwargs)

Overloaded function.

  1. apply_to(self: ostk.mathematics.geometry.d2.Transformation, point: ostk.mathematics.geometry.d2.object.Point) -> ostk.mathematics.geometry.d2.object.Point

    Apply the transformation to a point.

    Args:

    point (Point): The point to transform.

    Returns:

    Point: The transformed point.

    Example:
    >>> point = Point(1.0, 2.0)
    >>> translation = Transformation.translation([1.0, 1.0])
    >>> transformed = translation.apply_to(point)  # Point(2.0, 3.0)
    
  2. apply_to(self: ostk.mathematics.geometry.d2.Transformation, vector: numpy.ndarray[numpy.float64[2, 1]]) -> numpy.ndarray[numpy.float64[2, 1]]

    Apply the transformation to a vector.

    Args:

    vector (Vector2d): The vector to transform.

    Returns:

    Vector2d: The transformed vector.

    Example:
    >>> vector = numpy.array([1.0, 0.0])
    >>> rotation = Transformation.rotation(Angle.degrees(90.0))
    >>> transformed = rotation.apply_to(vector)  # [0.0, 1.0]
    
get_inverse(
self: ostk.mathematics.geometry.d2.Transformation,
) ostk.mathematics.geometry.d2.Transformation

Get the inverse transformation.

Returns:

The inverse transformation.

Return type:

Transformation

Example

>>> translation = Transformation.translation([1.0, 2.0])
>>> inverse = translation.get_inverse()  # Translation by [-1.0, -2.0]
get_matrix(
self: ostk.mathematics.geometry.d2.Transformation,
) numpy.ndarray[numpy.float64[3, 3]]

Get the transformation matrix.

Returns:

The 3x3 transformation matrix in homogeneous coordinates.

Return type:

Matrix3d

Example

>>> transformation = Transformation.identity()
>>> matrix = transformation.get_matrix()  # 3x3 identity matrix
get_type(
self: ostk.mathematics.geometry.d2.Transformation,
) ostk::mathematics::geometry::d2::Transformation::Type

Get the type of the transformation.

Returns:

The transformation type (Identity, Translation, Rotation, etc.).

Return type:

Transformation.Type

Example

>>> transformation = Transformation.identity()
>>> transformation.get_type()  # Transformation.Type.Identity
static identity() ostk.mathematics.geometry.d2.Transformation

Create an identity transformation (no change).

Returns:

The identity transformation.

Return type:

Transformation

Example

>>> identity = Transformation.identity()
>>> point = Point(1.0, 2.0)
>>> identity.apply_to(point)  # Point(1.0, 2.0) - unchanged
is_defined(self: ostk.mathematics.geometry.d2.Transformation) bool

Check if the transformation is defined.

Returns:

True if the transformation is defined, False otherwise.

Return type:

bool

Example

>>> transformation = Transformation.identity()
>>> transformation.is_defined()  # True
static rotation(
rotation_angle: ostk::mathematics::geometry::Angle,
) ostk.mathematics.geometry.d2.Transformation

Create a rotation transformation around the origin.

Parameters:

rotation_angle (Angle) -- The rotation angle.

Returns:

The rotation transformation.

Return type:

Transformation

Example

>>> rotation = Transformation.rotation(Angle.degrees(90.0))
>>> point = Point(1.0, 0.0)
>>> rotation.apply_to(point)  # Point(0.0, 1.0)
static rotation_around(
point: ostk.mathematics.geometry.d2.object.Point,
rotation_angle: ostk::mathematics::geometry::Angle,
) ostk.mathematics.geometry.d2.Transformation

Create a rotation transformation around a specific point.

Parameters:
  • point (Point) -- The center point of rotation.

  • rotation_angle (Angle) -- The rotation angle.

Returns:

The rotation transformation around the specified point.

Return type:

Transformation

Example

>>> center = Point(1.0, 1.0)
>>> rotation = Transformation.rotation_around(center, Angle.degrees(90.0))
>>> point = Point(2.0, 1.0)
>>> rotation.apply_to(point)  # Point(1.0, 2.0)
static string_from_type(
type: ostk::mathematics::geometry::d2::Transformation::Type,
) ostk.core.type.String

Get the string representation of a transformation type.

Parameters:

type (Transformation.Type) -- The transformation type.

Returns:

String representation of the type.

Return type:

str

Example

>>> Transformation.string_from_type(Transformation.Type.Translation)  # "Translation"
static translation(
translation_vector: numpy.ndarray[numpy.float64[2, 1]],
) ostk.mathematics.geometry.d2.Transformation

Create a translation transformation.

Parameters:

translation_vector (Vector2d) -- The translation vector.

Returns:

The translation transformation.

Return type:

Transformation

Example

>>> translation = Transformation.translation([1.0, 2.0])
>>> point = Point(0.0, 0.0)
>>> translation.apply_to(point)  # Point(1.0, 2.0)
static type_of_matrix(
matrix: numpy.ndarray[numpy.float64[3, 3]],
) ostk::mathematics::geometry::d2::Transformation::Type

Determine the transformation type from a matrix.

Parameters:

matrix (Matrix3d) -- The transformation matrix to analyze.

Returns:

The detected transformation type.

Return type:

Transformation.Type

Example

>>> import numpy as np
>>> matrix = numpy.eye(3)
>>> Transformation.type_of_matrix(matrix)  # Transformation.Type.Identity
static undefined() ostk.mathematics.geometry.d2.Transformation

Create an undefined transformation.

Returns:

An undefined transformation.

Return type:

Transformation

Example

>>> undefined_transform = Transformation.undefined()
>>> undefined_transform.is_defined()  # False