Struct hrbf::Hrbf

source ·
pub struct Hrbf<T, K>where
    T: Real,
    K: Kernel<T>,{ /* private fields */ }
Expand description

An HRBF potential field.

The field and its first and second derivatives can be queried at any 3D position. Additionally this field can be reset with a different set of points and normals using one of the fit, fit_to_points, offset_fit, or offset_fit_to_points methods. Some advanced functionality is also exposed (see individual methods for details).

Implementations§

source§

impl<T, K> Hrbf<T, K>where T: Real, K: Kernel<T> + Clone + Default,

source

pub fn sites(&self) -> &[Point3<T>]

Returns a reference to the vector of site locations used by this HRBF.

source

pub fn betas(&self) -> &[Vector4<T>]

(Advanced) Returns a reference to the vector of 4D weight vectors, which determine the global HRBF potential.

These are the unknowns computed during fitting. Each 4D vector has the structure [aⱼ; bⱼ] per site j where a is a scalar weighing the contribution from the kernel at site j and b is a 3D vector weighin the contribution from the kernel gradient at site j to the total HRBF potential.

source

pub fn fit(&mut self, normals: &[Vector3<T>]) -> Result<&mut Self>

Fit the current HRBF to the sites, with which this HRBF was built.

Normals dictate the direction of the HRBF gradient at the specified sites. Return a mutable reference to Self if successful.

source

pub fn fit_to_points( &mut self, points: &[Point3<T>], normals: &[Vector3<T>] ) -> Result<&mut Self>

Fit the current HRBF to the given data.

Return a mutable reference to Self if successful. NOTE: Currently, points must be the same size as sites.

source

pub fn offset_fit( &mut self, offsets: &[T], normals: &[Vector3<T>] ) -> Result<&mut Self>

Fit the current HRBF to the sites, with which this HRBF was built, offset by the given offsets.

The resulting HRBF field is equal to offsets at the sites. and has a gradient equal to normals. Return a mutable reference to Self if successful.

source

pub fn offset_fit_to_points( &mut self, points: &[Point3<T>], offsets: &[T], normals: &[Vector3<T>] ) -> Result<&mut Self>

Fit the current HRBF to the given data.

The resulting HRBF field is equal to offsets at the provided points and has a gradient equal to normals. Return a mutable reference to Self if successful. NOTE: Currently, points must be the same size as sites.

source

pub fn eval(&self, p: Point3<T>) -> T

Evaluate the HRBF at point p.

source

pub fn grad(&self, p: Point3<T>) -> Vector3<T>

Gradient of the HRBF function at point p.

source

pub fn hess(&self, p: Point3<T>) -> Matrix3<T>

Compute the Hessian of the HRBF function.

source

pub fn fit_block(&self, p: Point3<T>, j: usize) -> Matrix4<T>

(Advanced) Recall that the HRBF fit is done as

∑ⱼ ⎡  𝜙(𝑥ᵢ - 𝑥ⱼ)  ∇𝜙(𝑥ᵢ - 𝑥ⱼ)'⎤ ⎡ 𝛼ⱼ⎤ = ⎡ 0 ⎤
   ⎣ ∇𝜙(𝑥ᵢ - 𝑥ⱼ) ∇∇𝜙(𝑥ᵢ - 𝑥ⱼ) ⎦ ⎣ 𝛽ⱼ⎦   ⎣ 𝑛ᵢ⎦

for every HRBF site i, where the sum runs over HRBF sites j where 𝜙(𝑥) = 𝜑(||𝑥||) for one of the basis kernels we define in kernel If we rewrite the equation above as

∑ⱼ Aⱼ(𝑥ᵢ)bⱼ = rᵢ

this function returns the matrix Aⱼ(p).

This is the symmetric 4x4 matrix block that is used to fit the HRBF coefficients. This is equivalent to stacking the vector from eval_block on top of the 3x4 matrix returned by grad_block. This function is more efficient than evaluating eval_block and grad_block. This is [g ∇g]' = [𝜙 (∇𝜙)'; ∇𝜙 ∇(∇𝜙)'] in MATLAB notation.

source

pub fn grad_fit_block_prod( &self, p: Point3<T>, b: Vector4<T>, j: usize ) -> Matrix3x4<T>

(Advanced) Using the same notation as above, this function returns the matrix ∇(Aⱼ(p)b)'

source

pub fn hess_fit_prod(&self, p: Point3<T>, c: Vector4<T>) -> Matrix3<T>

Sum of hess_fit_prod_block evaluated at all sites.

Trait Implementations§

source§

impl<T, K> Clone for Hrbf<T, K>where T: Real + Clone, K: Kernel<T> + Clone,

source§

fn clone(&self) -> Hrbf<T, K>

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, K> Debug for Hrbf<T, K>where T: Real + Debug, K: Kernel<T> + Debug,

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, K> RefUnwindSafe for Hrbf<T, K>where K: RefUnwindSafe, T: RefUnwindSafe,

§

impl<T, K> Send for Hrbf<T, K>where K: Send,

§

impl<T, K> Sync for Hrbf<T, K>where K: Sync,

§

impl<T, K> Unpin for Hrbf<T, K>where K: Unpin, T: Unpin,

§

impl<T, K> UnwindSafe for Hrbf<T, K>where K: UnwindSafe, 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> Same<T> for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere 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 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.