MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/splashsurf / evaluate_gradient

Method evaluate_gradient

splashsurf_lib/src/kernel.rs:110–130  ·  view source on GitHub ↗

Evaluates the gradient of the cubic spline kernel at the position `x`

(&self, x: Vector3<R>)

Source from the content-addressed store, hash-verified

108
109 /// Evaluates the gradient of the cubic spline kernel at the position `x`
110 fn evaluate_gradient(&self, x: Vector3<R>) -> Vector3<R> {
111 // Kernel gradient is given by
112 // df/dq * dq/dr * dr/dx
113 // where:
114 // f is the cubic spline
115 // q is the spline parameter
116 // r is the radial distance
117 // x is the position where the kernel gradient is evaluated
118
119 // Radial distance is norm of position
120 let r = x.norm();
121 // Normalize the position vector: points into direction of gradient due to symmetry
122 let drdx = x.unscale(r);
123
124 let q = (r + r) / self.compact_support_radius;
125
126 let dfdq = Self::cubic_function_dq(q);
127 let dqdr = (R::one() + R::one()) / self.compact_support_radius;
128
129 drdx.scale(self.normalization * dfdq * dqdr)
130 }
131
132 /// Evaluates the norm of the gradient of the cubic spline kernel at the radial distance `r`
133 fn evaluate_gradient_norm(&self, r: R) -> R {

Callers

nothing calls this directly

Calls 1

scaleMethod · 0.80

Tested by

no test coverage detected