pub struct Transform { /* private fields */ }Expand description
A two-dimensional affine transform in double-precision design coordinates.
Coefficients are column-major [xx, yx, xy, yy, translation_x, translation_y].
Positive rotation is clockwise in the downward-positive coordinate system.
Self::then applies transforms in reading order, not matrix-product order.
Device-space geometry retains these f64 coefficients until explicit storage boundaries.
Implementations§
Source§impl Transform
impl Transform
Sourcepub const fn from_coefficients(coefficients: [f64; 6]) -> Self
pub const fn from_coefficients(coefficients: [f64; 6]) -> Self
Preserves raw affine coefficients; consuming geometry validates them.
Sourcepub const fn coefficients(self) -> [f64; 6]
pub const fn coefficients(self) -> [f64; 6]
Returns column-major affine coefficients without reducing precision.
Sourcepub const fn translate(horizontal: f64, vertical: f64) -> Self
pub const fn translate(horizontal: f64, vertical: f64) -> Self
Translates positions without changing vectors.
Sourcepub fn rotate(radians: f64) -> Self
pub fn rotate(radians: f64) -> Self
Rotates clockwise around the coordinate origin, in radians.
Sourcepub const fn scale(factor: f64) -> Self
pub const fn scale(factor: f64) -> Self
Uniformly scales around the coordinate origin; negative values reflect.
Sourcepub const fn scale_non_uniform(horizontal: f64, vertical: f64) -> Self
pub const fn scale_non_uniform(horizontal: f64, vertical: f64) -> Self
Scales each axis independently around the coordinate origin.
Sourcepub fn skew(horizontal: f64, vertical: f64) -> Self
pub fn skew(horizontal: f64, vertical: f64) -> Self
Skews each axis by the tangent of its angle in radians. Both shears act in one matrix, rather than as sequential operations.
Sourcepub fn then(self, next: Self) -> Self
pub fn then(self, next: Self) -> Self
Applies this transform first, followed by next.
use motion_core::{Point, Transform};
let transform = Transform::translate(10.0, 0.0).then(Transform::scale(2.0));
assert_eq!(transform.apply(Point::new(1.0, 3.0)), Point::new(22.0, 6.0));Sourcepub fn apply_vector(self, vector: Vector2) -> Vector2
pub fn apply_vector(self, vector: Vector2) -> Vector2
Maps a displacement, ignoring translation.
Sourcepub fn inverse(self) -> Option<Self>
pub fn inverse(self) -> Option<Self>
Inverts a finite nonsingular transform when its inverse remains finite.
Returns None for singular/nonfinite inputs or unrepresentable results.
Rows are scaled before computing the determinant to avoid ordinary
underflow/overflow for extremely small, large or unequal axis scales.
Sourcepub fn decompose(self) -> Option<TransformComponents>
pub fn decompose(self) -> Option<TransformComponents>
Decomposes into scale, horizontal shear, rotation, then translation.
The horizontal scale is positive; reflection is carried by vertical scale.
Returns None for singular/nonfinite inputs or nonfinite components.
Shear is stored as a coefficient, not an angle, to avoid losing precision
when a large tangent is rounded to a right angle.
Sourcepub fn interpolate(&self, target: &Self, progress: f64) -> Self
pub fn interpolate(&self, target: &Self, progress: f64) -> Self
Interpolates decomposed components and takes the shortest rotation arc. A half-turn tie rotates clockwise; progress may extrapolate. Exact zero/one return the original matrices. If either endpoint cannot be decomposed, coefficients interpolate directly, allowing singular endpoints such as zero-scale entrances. Reflection changes can pass through a singular scale.
Trait Implementations§
impl Copy for Transform
Source§impl Interpolate for Transform
impl Interpolate for Transform
Source§fn interpolate(&self, target: &Self, progress: f64) -> Self
fn interpolate(&self, target: &Self, progress: f64) -> Self
target with nominal progress zero at self and one at target. Read more