[][src]Trait arcs::algorithms::AffineTransformable

pub trait AffineTransformable {
    fn transform(
        &mut self,
        transform: Transform2D<f64, UnknownUnit, UnknownUnit>
    ); fn transformed(
        &self,
        transform: Transform2D<f64, UnknownUnit, UnknownUnit>
    ) -> Self
    where
        Self: Clone
, { ... } }

Something which can be transformed using an arbitrary [Transform2D] matrix and still be semantically valid.

This is often referred to as an Affine Transformation in mathematics.

Examples

You can use the various methods and constructors on euclid::Transform2D to build up the overall transform matrix to be applied.

use arcs_core::{Angle, algorithms::AffineTransformable};
use euclid::{Transform2D, approxeq::ApproxEq};

let point = Point::new(10.0, 10.0);
let transform_matrix = Transform2D::create_translation(-1.0, 1.0) // move the point
    .post_rotate(Angle::degrees(180.0)) // then rotate 180 degrees
    .post_scale(-1.0, 1.0); // then flip about y-axis

let got = point.transformed(transform_matrix);

// (Note: floating point operations are inherently inaccurate)
let expected = Point::new(9.0, -11.0);
assert!(got.approx_eq(&expected));

Required methods

fn transform(&mut self, transform: Transform2D<f64, UnknownUnit, UnknownUnit>)

Apply a transform matrix in-place.

Loading content...

Provided methods

fn transformed(
    &self,
    transform: Transform2D<f64, UnknownUnit, UnknownUnit>
) -> Self where
    Self: Clone

A convenience method for getting a transformed copy of this object.

Loading content...

Implementations on Foreign Types

impl<Space> AffineTransformable for Point2D<f64, Space>[src]

impl<Space> AffineTransformable for Vector2D<f64, Space>[src]

impl<'t, T> AffineTransformable for &'t mut T where
    T: AffineTransformable + ?Sized
[src]

Loading content...

Implementors

impl<Space> AffineTransformable for Line<Space>[src]

Loading content...