Skip to main content

social_repulsion_2d

Function social_repulsion_2d 

Source
pub fn social_repulsion_2d(
    x: f64,
    y: f64,
    vx: f64,
    vy: f64,
    radius: f64,
    nx: f64,
    ny: f64,
    nvx: f64,
    nvy: f64,
    n_radius: f64,
    params: &SocialForceParams,
) -> (f64, f64)
Expand description

Social repulsion + physical contact acceleration from a single neighbor in 2D.

Implements Helbing, Farkas & Vicsek (2000) Eq. 3, returning the mass-normalized result (m/s²) so it can be added directly to desired_force_2d and fed to integrate_euler_2d:

  • Exponential social repulsion: A * exp((r_ij - d) / B) * n_hat
  • Body compression (overlap only): k * g(r_ij - d) * n_hat
  • Sliding friction (overlap only): kappa * g(r_ij - d) * dv_t * t_hat

where r_ij = r_i + r_j (sum of body radii), d is center-to-center distance, n_hat is the unit normal pointing from the neighbor to self, g(x) = max(0, x), and dv_t is the tangential velocity difference. The Newton-scale coefficients are divided by params.mass before returning.

§Arguments

  • (x, y) - current agent position
  • (vx, vy) - current agent velocity
  • radius - current agent body radius
  • (nx, ny) - neighbor position
  • (nvx, nvy) - neighbor velocity
  • n_radius - neighbor body radius
  • params - SocialForceParams (uses mass for normalization)

Returns (ax, ay) - acceleration (m/s²) on the current agent.