pub struct Affine {
pub m: [f64; 6],
}Expand description
A 2D affine transform [a b c d e f] with the SVG convention:
x' = a·x + c·y + e
y' = b·x + d·y + fSerialized as a 6-element array.
Fields§
§m: [f64; 6]Coefficients [a, b, c, d, e, f].
Implementations§
Source§impl Affine
impl Affine
Sourcepub const SINGULAR_EPS: f64 = 1e-14
pub const SINGULAR_EPS: f64 = 1e-14
Determinants with magnitude below this are treated as singular.
Sourcepub fn rotate(angle: f64) -> Self
pub fn rotate(angle: f64) -> Self
Counter-clockwise rotation by angle radians about the origin.
Sourcepub fn rotate_about(angle: f64, center: Point) -> Self
pub fn rotate_about(angle: f64, center: Point) -> Self
Rotation about center.
Sourcepub fn scale_about(sx: f64, sy: f64, center: Point) -> Self
pub fn scale_about(sx: f64, sy: f64, center: Point) -> Self
Scale about center.
Sourcepub fn mirror(p: Point, dir: Vector) -> GeoResult<Self>
pub fn mirror(p: Point, dir: Vector) -> GeoResult<Self>
Reflection across the line through p with direction dir.
Sourcepub fn determinant(self) -> f64
pub fn determinant(self) -> f64
Determinant of the linear part.
Sourcepub fn is_identity(self) -> bool
pub fn is_identity(self) -> bool
Whether this is exactly the identity.
Sourcepub fn inverse(self) -> GeoResult<Self>
pub fn inverse(self) -> GeoResult<Self>
Inverse transform. Fails for singular or non-finite transforms.
Sourcepub fn apply_vector(self, v: Vector) -> Vector
pub fn apply_vector(self, v: Vector) -> Vector
Transform a vector (ignores translation).
Sourcepub fn translation(self) -> Vector
pub fn translation(self) -> Vector
Translation part.
Sourcepub fn linear_kind(self, rel: f64) -> LinearKind
pub fn linear_kind(self, rel: f64) -> LinearKind
Classify the linear part with relative tolerance rel.
Sourcepub fn rotation_angle(self) -> f64
pub fn rotation_angle(self) -> f64
Rotation angle of the linear part (meaningful for similarities).
Sourcepub fn is_axis_aligned(self, rel: f64) -> bool
pub fn is_axis_aligned(self, rel: f64) -> bool
Whether the linear part is a diagonal (axis aligned) scale with positive or negative factors: no rotation or shear.