ostk.mathematics.geometry.d2.Transformation¶
- class Transformation(
- self: ostk.mathematics.geometry.d2.Transformation,
- matrix: numpy.ndarray[numpy.float64[3, 3]],
Bases:
pybind11_objectCreate 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
Overloaded function.
Get the inverse transformation.
Get the transformation matrix.
Get the type of the transformation.
Create an identity transformation (no change).
Check if the transformation is defined.
Create a rotation transformation around the origin.
Create a rotation transformation around a specific point.
Get the string representation of a transformation type.
Create a translation transformation.
Determine the transformation type from a matrix.
Create an undefined transformation.
- class Type(self: ostk.mathematics.geometry.d2.Transformation.Type, value: int)¶
Bases:
pybind11_objectMembers:
Undefined
Identity
Translation
Rotation
Scaling
Reflection
Shear
Affine
- property name¶
- apply_to(*args, **kwargs)¶
Overloaded function.
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)
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( ) ostk.mathematics.geometry.d2.Transformation¶
Get the inverse transformation.
- Returns:
The inverse transformation.
- Return type:
Example
>>> translation = Transformation.translation([1.0, 2.0]) >>> inverse = translation.get_inverse() # Translation by [-1.0, -2.0]
- get_matrix( ) 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( ) ostk::mathematics::geometry::d2::Transformation::Type¶
Get the type of the transformation.
- Returns:
The transformation type (Identity, Translation, Rotation, etc.).
- Return 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:
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:
Example
>>> transformation = Transformation.identity() >>> transformation.is_defined() # True
- static rotation(
- rotation_angle: ostk::mathematics::geometry::Angle,
Create a rotation transformation around the origin.
- Parameters:
rotation_angle (Angle) -- The rotation angle.
- Returns:
The rotation transformation.
- Return type:
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,
Create a rotation transformation around a specific point.
- Parameters:
- Returns:
The rotation transformation around the specified point.
- Return type:
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,
Get the string representation of a transformation type.
- Parameters:
type (Transformation.Type) -- The transformation type.
- Returns:
String representation of the type.
- Return type:
Example
>>> Transformation.string_from_type(Transformation.Type.Translation) # "Translation"
- static translation(
- translation_vector: numpy.ndarray[numpy.float64[2, 1]],
Create a translation transformation.
- Parameters:
translation_vector (Vector2d) -- The translation vector.
- Returns:
The translation transformation.
- Return type:
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]],
Determine the transformation type from a matrix.
- Parameters:
matrix (Matrix3d) -- The transformation matrix to analyze.
- Returns:
The detected transformation type.
- Return 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:
Example
>>> undefined_transform = Transformation.undefined() >>> undefined_transform.is_defined() # False