Skip to main content

Hrbf

Struct 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 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<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> Freeze for Hrbf<T, K>
where K: Freeze,

§

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

§

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> UnsafeUnpin for Hrbf<T, K>
where K: UnsafeUnpin,

§

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