# Barrier¶

ipctk.barrier(d: float, dhat: float) float

Function that grows to infinity as d approaches 0 from the right.

$b(d) = -(d-\hat{d})^2\ln\left(\frac{d}{\hat{d}}\right)$
Parameters:
d: float

The distance.

dhat: float

Activation distance of the barrier.

Returns:

The value of the barrier function at d.

Derivative of the barrier function.

$b'(d) = (\hat{d}-d) \left( 2\ln\left( \frac{d}{\hat{d}} \right) - \frac{\hat{d}}{d} + 1\right)$
Parameters:
d: float

The distance.

dhat: float

Activation distance of the barrier.

Returns:

The derivative of the barrier wrt d.

ipctk.barrier_hessian(d: float, dhat: float) float

Second derivative of the barrier function.

$b''(d) = \left( \frac{\hat{d}}{d} + 2 \right) \frac{\hat{d}}{d} - 2\ln\left( \frac{d}{\hat{d}} \right) - 3$
Parameters:
d: float

The distance.

dhat: float

Activation distance of the barrier.

Returns:

The second derivative of the barrier wrt d.

ipctk.initial_barrier_stiffness(bbox_diagonal: float, dhat: float, average_mass: float, grad_energy: numpy.ndarray[numpy.float64[m, 1]], grad_barrier: numpy.ndarray[numpy.float64[m, 1]], min_barrier_stiffness_scale: float = 100000000000.0, dmin: float = 0) tuple[float, float]

Compute an inital barrier stiffness using the barrier potential gradient.

Parameters:
bbox_diagonal: float

Length of the diagonal of the bounding box of the scene.

dhat: float

Activation distance of the barrier.

average_mass: float

Average mass of all bodies.

Gradient of the elasticity energy function.

min_barrier_stiffness_scale: float = 100000000000.0

Scale used to premultiply the minimum barrier stiffness.

dmin: float = 0

Minimum distance between elements.

Returns:

The initial barrier stiffness. Maximum stiffness of the barrier.

Return type:

Tuple of

ipctk.update_barrier_stiffness(prev_min_distance: float, min_distance: float, max_barrier_stiffness: float, barrier_stiffness: float, bbox_diagonal: float, dhat_epsilon_scale: float = 1e-09, dmin: float = 0) float

Update the barrier stiffness if the distance is decreasing and less than dhat_epsilon_scale * diag.

Parameters:
prev_min_distance: float

Previous minimum distance between elements.

min_distance: float

Current minimum distance between elements.

max_barrier_stiffness: float

Maximum stiffness of the barrier.

barrier_stiffness: float

Current barrier stiffness.

bbox_diagonal: float

Length of the diagonal of the bounding box of the scene.

dhat_epsilon_scale: float = 1e-09

Update if distance is less than this fraction of the diagonal.

dmin: float = 0

Minimum distance between elements.

Returns:

The updated barrier stiffness.

Last update: Nov 12, 2023