Skip to main content

GeoVar

Struct 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. You can merge two instance with */*= operator.

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

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

Implementations§

Source§

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

Source

pub fn identity() -> Self

Create a new identity instance.

Source

pub fn new(trans: [f64; D], rot: R, scale: f64) -> Self

Create a new instance.

Source

pub fn from_trans(trans: [f64; D]) -> Self

Create a new instance from translation.

Source

pub fn from_rot(rot: R) -> Self

Create a new instance from rotation.

Source

pub fn from_scale(scale: f64) -> Self

Create a new instance from rotation.

Source

pub fn only_trans(self) -> Self

Create a new instance from translation.

Source

pub fn only_rot(self) -> Self

Create a new instance from rotation.

Source

pub fn only_rot_scale(self) -> Self

Create a new instance from rotation and scaling.

Source

pub fn with_trans(self, trans: [f64; D]) -> Self

With the translate property.

Source

pub fn with_rot(self, rot: R) -> Self

With the rotation property.

Source

pub fn with_scale(self, scale: f64) -> Self

With the scaling property.

Source

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

Merge inverse self and rhs. (rhs * self^T)

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

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

let a = Efd2::from_curve(curve1, false);
let b = Efd2::from_curve(curve2, false);
let geo = a.as_geo().to(b.as_geo());
assert!(curve_diff(&geo.transform(curve1), curve2) < EPS);
Source

pub fn inverse(&self) -> Self

Inverse self. (self^T/self^-1)

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

let efd = Efd2::from_curve(curve, false);
let curve = efd.recon(curve.len());
let curve_norm = efd.recon_norm(curve.len());
let curve = efd.as_geo().inverse().transform(curve);
Source

pub fn trans(&self) -> &[f64; D]

Get the translate property.

Source

pub fn rot(&self) -> &R

Get the rotation property.

Source

pub fn scale(&self) -> f64

Get the scaling property.

Source

pub fn set_trans(&mut self, trans: [f64; D])

Set the translate property.

Source

pub fn set_rot(&mut self, rot: R)

Set the rotation property.

Source

pub fn set_scale(&mut self, scale: f64)

Set the scaling property.

Source

pub fn transform_pt(&self, p: [f64; D]) -> [f64; D]

Transform a point.

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

Source

pub fn transform<C>(&self, curve: C) -> Vec<[f64; D]>
where C: Curve<D>,

Transform a contour with this information.

This function rotates first, then translates.

use efd::{tests::*, *};
let efd = Efd2::from_curve(curve, false);
// Normalize the curve
let curve_norm = efd.as_geo().inverse().transform(&curve);
Source

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

Transform a contour in-placed with this information.

Source

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

Transform an iterator contour and return a new iterator.

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 duplicate of the value. Read more
1.0.0 (const: unstable) · 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: RotHint<D>, const D: usize> Mul for GeoVar<R, D>

Source§

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

Source§

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

Source§

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

Source§

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

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

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

Source§

fn mul_assign(&mut self, rhs: &Self)

Performs the *= operation. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

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> 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, Right> ClosedMul<Right> for T
where T: Mul<Right, Output = T> + MulAssign<Right>,

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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

fn is_in_subset(&self) -> bool

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

fn to_subset_unchecked(&self) -> SS

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

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,

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.