pub struct SimpleTransform<T> {
    pub mirror: bool,
    pub rotation: Angle,
    pub magnification: T,
    pub displacement: Vector<T>,
}
Expand description

Describes a geometric transformation that consists of a optional mirroring along the x-axis followed by a rotation by a multiple of 90 degrees followed by a displacement.

Fields§

§mirror: bool

Mirror on the x-axis?

§rotation: Angle

Rotation by a multiple of 90 degrees.

§magnification: T

Enlargement.

§displacement: Vector<T>

Translation.

Implementations§

§

impl<T> SimpleTransform<T>

pub fn new( mirror: bool, rotation: Angle, magnification: T, displacement: Vector<T> ) -> SimpleTransform<T>

Create a new transformation.

§

impl<T> SimpleTransform<T>where T: Zero + One,

pub fn identity() -> SimpleTransform<T>

Get the identity transform.

pub fn translate<V>(v: V) -> SimpleTransform<T>where V: Into<Vector<T>>,

Create a translation by a vector.

pub fn rotate90(angle: Angle) -> SimpleTransform<T>

Create a rotation by an integer multiple of 90 degrees. Rotation center is (0, 0).

pub fn rotate_ccw90() -> SimpleTransform<T>

Rotate 90 degrees counter-clock wise.

pub fn rotate_cw90() -> SimpleTransform<T>

Rotate 90 degrees counter-clock wise.

pub fn mirror_x() -> SimpleTransform<T>

Create a transformation that mirrors at the x-axis.

pub fn mirror_y() -> SimpleTransform<T>

Create a transformation that mirrors at the y-axis.

pub fn scale(factor: T) -> SimpleTransform<T>

Create a scaling by a factor.

§

impl<T> SimpleTransform<T>where T: Copy + Mul<T, Output = T>,

pub fn transform_distance(&self, d: T) -> T

Transform a distance.

§

impl<T> SimpleTransform<T>where T: CoordinateType,

pub fn rotate90_around( angle: Angle, rotation_center: Point<T> ) -> SimpleTransform<T>

Create a rotation arount rotation_center by an integer multiple of 90 degrees.

pub fn transform_point(&self, p: Point<T>) -> Point<T>

Transform a single point.

pub fn inverse_transform_point(&self, p: Point<T>) -> Point<T>

Inverse-transform a single point.

pub fn to_matrix_transform(&self) -> Matrix3dTransform<T>

Convert to a matrix transformation.

pub fn then(&self, t: &SimpleTransform<T>) -> SimpleTransform<T>

Return a new transformation that is equal to applying first self then t.

Trait Implementations§

§

impl<T> Clone for SimpleTransform<T>where T: Clone,

§

fn clone(&self) -> SimpleTransform<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T> Debug for SimpleTransform<T>where T: Debug,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<T> Default for SimpleTransform<T>where T: CoordinateType,

§

fn default() -> SimpleTransform<T>

Returns the “default value” for a type. Read more
§

impl<'de, T> Deserialize<'de> for SimpleTransform<T>where T: Deserialize<'de>,

§

fn deserialize<__D>( __deserializer: __D ) -> Result<SimpleTransform<T>, <__D as Deserializer<'de>>::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl<T> PartialEq<SimpleTransform<T>> for SimpleTransform<T>where T: PartialEq<T>,

§

fn eq(&self, other: &SimpleTransform<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T> Serialize for SimpleTransform<T>where T: Serialize,

§

fn serialize<__S>( &self, __serializer: __S ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl<T, Dst> TryCastCoord<T, Dst> for SimpleTransform<T>where T: CoordinateType + NumCast, Dst: CoordinateType + NumCast,

§

type Output = SimpleTransform<Dst>

Output type of the cast. This is likely the same geometrical type just with other coordinate types.
§

fn try_cast( &self ) -> Option<<SimpleTransform<T> as TryCastCoord<T, Dst>>::Output>

Try to cast to target data type. Read more
§

fn cast(&self) -> Self::Output

Cast to target data type. Read more
§

impl<T> Copy for SimpleTransform<T>where T: Copy,

§

impl<T> Eq for SimpleTransform<T>where T: Eq,

§

impl<T> StructuralEq for SimpleTransform<T>

§

impl<T> StructuralPartialEq for SimpleTransform<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for SimpleTransform<T>where T: RefUnwindSafe,

§

impl<T> Send for SimpleTransform<T>where T: Send,

§

impl<T> Sync for SimpleTransform<T>where T: Sync,

§

impl<T> Unpin for SimpleTransform<T>where T: Unpin,

§

impl<T> UnwindSafe for SimpleTransform<T>where T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,