Struct efd::GeoVar

source ·
pub struct GeoVar<R: RotHint<D>, const D: usize> { /* private fields */ }
Expand description

Geometric variables.

This type record the information of raw coefficients.

Implementations§

source§

impl<R, const D: usize> GeoVar<R, D>
where R: RotHint<D>,

source

pub fn new(trans: Coord<D>, rot: R, scale: f64) -> Self

Create a new transform type.

source

pub fn identity() -> Self

Create with identity matrix.

source

pub fn transform_pt(&self, p: Coord<D>) -> Coord<D>

Transform a point.

Please see GeoVar::transform() for more information.

source

pub fn transform<C>(&self, curve: C) -> Vec<Coord<D>>
where C: AsRef<[Coord<D>]>,

Transform a contour with this information.

This function rotates first, then translates.

use efd::{tests::*, *};
let path1 = efd.as_geo().transform(&path);
let path1_inv = geo.inverse().transform(&path1);
source

pub fn transform_inplace<C>(&self, curve: C)
where C: AsMut<[Coord<D>]>,

Transform a contour in-placed with this information.

source

pub fn transform_iter<'a, C>( &'a self, curve: C ) -> impl Iterator<Item = Coord<D>> + 'a
where C: IntoIterator<Item = Coord<D>> + 'a,

Transform an iterator contour.

source

pub fn to(&self, rhs: &Self) -> Self

Merge inverse self and rhs matrices.

It can be used on a not normalized contour a transforming to b.

use efd::{tests::*, Efd2};

let a = Efd2::from_curve(path1, false);
let b = Efd2::from_curve(path2, false);
let geo = a.as_geo().to(b.as_geo());
assert!(curve_diff(&geo.transform(path1), path2) < EPS);
source

pub fn apply(&self, rhs: &Self) -> Self

Merge two matrices.

Same as rhs * self.

use efd::{tests::*, Efd2};

let a = Efd2::from_curve(path1, false);
let b = Efd2::from_curve(path2, false);
let geo = b.as_geo() * a.as_geo().inverse();
assert!(curve_diff(&geo.transform(path1), path2) < EPS);
source

pub fn inverse(&self) -> Self

Inverse matrices.

use efd::{tests::*, Efd2};

let efd = Efd2::from_curve(path, false);
let path = efd.generate(path.len());
let path_norm = efd.generate_norm(path.len());
let path = efd.as_geo().inverse().transform(path);
source

pub fn trans(&self) -> Coord<D>

Translate property.

source

pub fn rot(&self) -> &R

Rotation property.

source

pub fn scale(&self) -> f64

Scaling property.

Trait Implementations§

source§

impl<R: Clone + RotHint<D>, const D: usize> Clone for GeoVar<R, D>

source§

fn clone(&self) -> GeoVar<R, D>

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<R, const D: usize> Debug for GeoVar<R, D>
where R: RotHint<D>,

source§

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

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

impl<R: RotHint<D>, const D: usize> Default for GeoVar<R, D>

source§

fn default() -> Self

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

impl<R, const D: usize> Mul<&GeoVar<R, D>> for GeoVar<R, D>
where R: RotHint<D>,

§

type Output = GeoVar<R, D>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: &Self) -> Self::Output

Performs the * operation. Read more
source§

impl<R, const D: usize> Mul<GeoVar<R, D>> for &GeoVar<R, D>
where R: RotHint<D>,

§

type Output = GeoVar<R, D>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: GeoVar<R, D>) -> Self::Output

Performs the * operation. Read more
source§

impl<R, const D: usize> Mul for &GeoVar<R, D>
where R: RotHint<D>,

§

type Output = GeoVar<R, D>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
source§

impl<R, const D: usize> Mul for GeoVar<R, D>
where R: RotHint<D>,

§

type Output = GeoVar<R, D>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more

Auto Trait Implementations§

§

impl<R, const D: usize> RefUnwindSafe for GeoVar<R, D>
where R: RefUnwindSafe,

§

impl<R, const D: usize> Send for GeoVar<R, D>
where R: Send,

§

impl<R, const D: usize> Sync for GeoVar<R, D>
where R: Sync,

§

impl<R, const D: usize> Unpin for GeoVar<R, D>
where R: Unpin,

§

impl<R, const D: usize> UnwindSafe for GeoVar<R, D>
where R: 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> 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> Same for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

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

§

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>,

§

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.