Inverse-Power Barrier

template <typename T = double>
class InversePowerBarrier : public ipc::BarrierBase<double>;

Inheritance diagram for ipc::InversePowerBarrier:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "2" [label="ipc::BarrierBase< T >" tooltip="ipc::BarrierBase< T >"] "1" [label="ipc::InversePowerBarrier< T >" tooltip="ipc::InversePowerBarrier< T >" fillcolor="#BFBFBF"] "1" -> "2" [dir=forward tooltip="public-inheritance"] }

Collaboration diagram for ipc::InversePowerBarrier:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "2" [label="ipc::BarrierBase< T >" tooltip="ipc::BarrierBase< T >"] "1" [label="ipc::InversePowerBarrier< T >" tooltip="ipc::InversePowerBarrier< T >" fillcolor="#BFBFBF"] "1" -> "2" [dir=forward tooltip="public-inheritance"] }

Inverse-power barrier with smooth compact support.

\[ b(d) = \frac{h(d,\hat{d})}{d^p}, \quad h(d,\hat{d}) = 2\,B!\left(\frac{2d}{\hat{d}}\right) \]

where \(B\) is the standard cubic B-spline basis function and \(p > 0\) is the power parameter. The window \(h\) vanishes smoothly at \(d = \hat{d}\) (C² contact), ensuring \(b(d)=0\) for \(d\ge\hat{d}\), while \(b(d)\to+\infty\) as \(d\to 0^+\).

Public Functions

inline explicit InversePowerBarrier(const double power);
Parameters:
const double power

The power \(p > 0\) controlling the singularity at d = 0.

Throws:

std::invalid_argument – if power is not positive and finite. With p = 0 the barrier stays bounded at contact (allowing interpenetration), and with p < 0 it attracts instead of repels.

virtual T operator()(const T d, const T dhat) const override;

b(d) = h(d, d̂) / d^p.

Parameters:
const T d

Distance (must be > 0 for a finite value).

const T dhat

Activation distance of the barrier.

Returns:

The value of the barrier function at d.

virtual T first_derivative(const T d, const T dhat) const override;

First derivative b’(d) = (h’·d − p·h) / d^(p+1).

Parameters:
const T d

Distance.

const T dhat

Activation distance of the barrier.

Returns:

The first derivative of the barrier function at d.

virtual T second_derivative(const T d, const T dhat) const override;

Second derivative b’’(d) = (h’’·d² − 2p·h’·d + p(p+1)·h) / d^(p+2).

Parameters:
const T d

Distance.

const T dhat

Activation distance of the barrier.

Returns:

The second derivative of the barrier function at d.

virtual T units(const T dhat) const override;

Get the units of the barrier function (d̂^{-p}).

Parameters:
const T dhat

The activation distance of the barrier.

Returns:

The units of the barrier function.

inline double power() const;

The power p used in the barrier.

Private Members

double m_power;

p > 0.

We keep it as a double, whatever T is, because it is a parameter of the barrier rather than a per-lane input.

Private Static Functions

static void h_and_derivs(T d, T dhat, T& h, T& dh, T& ddh);

Evaluate the B-spline window h(d, dhat) and its first two derivatives with respect to d.

h(d) = 2 * B(2d/dhat) where B is the cubic B-spline: B(t) = 2/3 - t² + t³/2 for 0 ≤ t < 1 B(t) = (2-t)³ / 6 for 1 ≤ t < 2 B(t) = 0 for t ≥ 2