Struct efd::PosedEfd

source ·
pub struct PosedEfd<const D: usize>
where U<D>: EfdDim<D>,
{ /* private fields */ }
Expand description

A shape with a pose described by EFD.

These are the same as Efd except that it has a pose, and the data are always normalized and readonly.

Start with PosedEfd::from_series() and its related methods.

Pose Representation

Pose is represented by an unit vector, which is rotated by the rotation of the original shape.

Implementations§

source§

impl PosedEfd<2>

source

pub fn from_angles<C>(curve: C, angles: &[f64], is_open: bool) -> Self
where C: Curve<2>,

Calculate the coefficients from a curve and its angles from each point.

source

pub fn from_angles_harmonic<C>( curve: C, angles: &[f64], is_open: bool, harmonic: usize ) -> Self
where C: Curve<2>,

Calculate the coefficients from a curve and its angles from each point.

The harmonic is the number of the coefficients to be calculated.

source§

impl<const D: usize> PosedEfd<D>
where U<D>: EfdDim<D>,

source

pub const fn from_parts_unchecked(curve: Efd<D>, pose: Efd<D>) -> Self

Create a new PosedEfd from two Efds. (curve and pose)

See also PosedEfd::into_inner().

source

pub fn from_series<C1, C2>(curve1: C1, curve2: C2, is_open: bool) -> Self
where C1: Curve<D>, C2: Curve<D>,

Calculate the coefficients from two series of points.

The second series is the pose series, the curve2[i] has the same time as curve[i].

source

pub fn from_series_harmonic<C1, C2>( curve1: C1, curve2: C2, is_open: bool, harmonic: usize ) -> Self
where C1: Curve<D>, C2: Curve<D>,

Calculate the coefficients from two series of points.

The harmonic is the number of the coefficients to be calculated.

source

pub fn from_uvec<C, V>(curve: C, vectors: V, is_open: bool) -> Self
where C: Curve<D>, V: Curve<D>,

Calculate the coefficients from a curve and its unit vectors from each point.

See also PosedEfd::from_uvec_unchecked() if you want to skip the unit vector calculation.

source

pub fn from_uvec_harmonic<C, V>( curve: C, vectors: V, is_open: bool, harmonic: usize ) -> Self
where C: Curve<D>, V: Curve<D>,

Calculate the coefficients from a curve and its unit vectors from each point.

See also PosedEfd::from_uvec_harmonic_unchecked() if you want to skip the unit vector calculation.

source

pub fn from_uvec_unchecked<C, V>(curve: C, vectors: V, is_open: bool) -> Self
where C: Curve<D>, V: Curve<D>,

Calculate the coefficients from a curve and its unit vectors from each point.

source

pub fn from_uvec_harmonic_unchecked<C, V>( curve: C, vectors: V, is_open: bool, harmonic: usize ) -> Self
where C: Curve<D>, V: Curve<D>,

Calculate the coefficients from a curve and its unit vectors from each point.

The harmonic is the number of the coefficients to be calculated.

source

pub fn fourier_power_anaysis<T>(self, threshold: T) -> Self
where Option<f64>: From<T>,

Use Fourier Power Anaysis (FPA) to reduce the harmonic number.

The default threshold is 99.99%.

See also Efd::fourier_power_anaysis().

Panics

Panics if the threshold is not in 0..1, or the harmonic is zero.

source

pub fn set_harmonic(&mut self, harmonic: usize)

Set the harmonic number of the coefficients.

Panics

Panics if the harmonic is zero or greater than the current harmonic.

source

pub fn into_inner(self) -> (Efd<D>, Efd<D>)

Consume self and return the parts of this type. The first is the curve coefficients, and the second is the pose coefficients.

See also PosedEfd::from_parts_unchecked().

source

pub fn is_open(&self) -> bool

Check if the described curve is open.

source

pub fn harmonic(&self) -> usize

Get the harmonic number of the coefficients.

source

pub fn is_valid(&self) -> bool

Check if the coefficients are valid.

It is only helpful if this object is constructed by PosedEfd::from_parts_unchecked().

source

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

Calculate the L1 distance between two coefficient set.

For more distance methods, please see Distance.

source

pub fn curve_efd(&self) -> &Efd<D>

Get a reference to the curve coefficients.

source

pub fn pose_efd(&self) -> &Efd<D>

Get a reference to the posed coefficients.

source

pub fn generate(&self, n: usize, len: f64) -> (Vec<Coord<D>>, Vec<Coord<D>>)

Obtain the curve and pose for visualization.

The len is the length of the pose vector.

source

pub fn generate_half( &self, n: usize, len: f64 ) -> (Vec<Coord<D>>, Vec<Coord<D>>)

Obtain the curve and pose for visualization in half range.

The len is the length of the pose vector.

source

pub fn generate_by(&self, t: &[f64], len: f64) -> (Vec<Coord<D>>, Vec<Coord<D>>)

Obtain the curve and pose for visualization from a series of time t.

Trait Implementations§

source§

impl<const D: usize> Clone for PosedEfd<D>
where U<D>: EfdDim<D>,

source§

fn clone(&self) -> PosedEfd<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<const D: usize> Debug for PosedEfd<D>
where U<D>: EfdDim<D>,

source§

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

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

impl<const D: usize> Distance for PosedEfd<D>
where U<D>: EfdDim<D>,

source§

fn err_buf(&self, rhs: &Self) -> Vec<f64>

Calculate the error between each pair of datas.
source§

fn square_err(&self, rhs: &Self) -> f64

Calculate the square error.
source§

fn l0_norm(&self, rhs: &Self) -> f64

Calculate the L0 norm of the error.
source§

fn l1_norm(&self, rhs: &Self) -> f64

Calculate the L1 norm of the error.
source§

fn l2_norm(&self, rhs: &Self) -> f64

Calculate the L2 norm of the error.
source§

fn lp_norm(&self, rhs: &Self, p: i32) -> f64

Calculate the Lp norm of the error.

Auto Trait Implementations§

§

impl<const D: usize> !RefUnwindSafe for PosedEfd<D>

§

impl<const D: usize> !Send for PosedEfd<D>

§

impl<const D: usize> !Sync for PosedEfd<D>

§

impl<const D: usize> !Unpin for PosedEfd<D>

§

impl<const D: usize> !UnwindSafe for PosedEfd<D>

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.