Struct SimpleTransform

Source
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§

Source§

impl<T> SimpleTransform<T>

Source

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

Create a new transformation.

Source§

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

Source

pub fn identity() -> SimpleTransform<T>

Get the identity transform.

Source

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

Create a translation by a vector.

Source

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

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

Source

pub fn rotate_ccw90() -> SimpleTransform<T>

Rotate 90 degrees counter-clock wise.

Source

pub fn rotate_cw90() -> SimpleTransform<T>

Rotate 90 degrees counter-clock wise.

Source

pub fn mirror_x() -> SimpleTransform<T>

Create a transformation that mirrors at the x-axis.

Source

pub fn mirror_y() -> SimpleTransform<T>

Create a transformation that mirrors at the y-axis.

Source

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

Create a scaling by a factor.

Source§

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

Source

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

Transform a distance.

Source§

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

Source

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.

Source

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

Transform a single point.

Source

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

Inverse-transform a single point.

Source

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

Convert to a matrix transformation.

Source

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

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

Trait Implementations§

Source§

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

Source§

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
Source§

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

Source§

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

Formats the value using the given formatter. Read more
Source§

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

Source§

fn default() -> SimpleTransform<T>

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

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

Source§

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
Source§

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

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

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

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

Source§

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
Source§

impl<T, Dst> TryCastCoord<T, Dst> for SimpleTransform<T>

Source§

type Output = SimpleTransform<Dst>

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

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

Try to cast to target data type. Read more
Source§

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

Cast to target data type. Read more
Source§

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

Source§

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

Source§

impl<T> StructuralPartialEq for SimpleTransform<T>

Auto Trait Implementations§

§

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

§

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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

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

Source§

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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