tlab-vehicle-physics-rs is a pure Rust tire and vehicle dynamics solver implementing Hans Pacejka's empirical Magic Formula for longitudinal traction, lateral cornering force, and self-aligning torque. It models load sensitivity, camber thrust, and friction-circle combined slip for realistic racing and drift simulations.
$ cargo add tlab-vehicle-physics-rs
Tune Hans Pacejka's semi-empirical parameters in real time and observe live friction response and cornering stiffness.
At low slip angles ($\alpha < 5^\circ$), pneumatic trail acts behind the tire patch, producing strong self-centering torque ($M_z$). As slip approaches peak grip ($\approx 7^\circ$), $M_z$ peaks and then rapidly decays to near-zero as trail vanishes. In deep drift angles ($\alpha > 12^\circ$), torque relaxes, naturally rotating the steering wheel into counter-steer!
TLabVehiclePhysics C# translation ported to idiomatic, memory-safe, zero-allocation Rust.
Semi-empirical formulation governing tire adhesion through slip stiffness ($B$), curve shape ($C$), peak friction ($D$), curvature ($E$), and horizontal/vertical shifts.
Calculates longitudinal slip ratio $\kappa$ and lateral slip angle $\alpha$ with numerical low-speed singularity regularization to guarantee rock-solid standstill stability.
Coupled Pacejka interaction attenuation factors $G_{xa}$ and $G_{yk}$. Acceleration wheelspin attenuates lateral cornering grip; lateral slide reduces braking capability.
Realistic contact patch center-of-pressure offset. Produces accurate self-aligning torque ($M_z$) for force feedback steering wheels and authentic drift counter-steer.
Tire friction coefficient diminishes as normal load $F_z$ increases, accurately simulating vehicle weight transfer, body roll, and understeer/oversteer balance.
Smooth exponential transition from static peak friction $\mu_{\text{peak}}$ towards kinetic sliding friction $\mu_{\text{slide}}$ when tire traction limit is exceeded.
The analytical equations driving each computation in the Rust crate.
Direct formula evaluated in TLabVehiclePhysics C# port:
Bilinear interpolation between discrete load-dependent Pacejka curve presets across vertical wheel force slices $F_{z,1}, F_{z,2}, \dots, F_{z,n}$.
Add tlab-vehicle-physics to your project and evaluate full tire kinematics in 5 lines of Rust.
[dependencies]
tlab-vehicle-physics = "0.1"
glam = "0.29"
use tlab_vehicle_physics::prelude::*;
fn main() {
// 1. Instantiate a high-performance tire model with Pacejka coefficients
let tire = TireModel::default();
// 2. Supply instantaneous wheel kinematics from physics engine
let angular_velocity = 32.0; // rad/s (~305 RPM)
let wheel_radius = 0.35; // 35 cm rolling radius
let longitudinal_velocity = 10.0; // 10 m/s (36 km/h) forward
let lateral_velocity = 1.2; // 1.2 m/s sideways drift
let normal_load = 4_200.0; // 4,200 N normal force
let camber_angle_rad = -1.5_f32.to_radians(); // -1.5° camber
// 3. Evaluate comprehensive tire kinetics
let output = tire.evaluate(
angular_velocity, wheel_radius,
longitudinal_velocity, lateral_velocity,
normal_load, camber_angle_rad,
);
println!("Longitudinal Force Fx: {:.1} N", output.longitudinal_force);
println!("Lateral Force Fy: {:.1} N", output.lateral_force);
println!("Self-Aligning Torque Mz: {:.2} N·m", output.aligning_torque);
println!("Grip Utilization: {:.1}%", output.grip_utilization * 100.0);
println!("Is Sliding/Drifting: {}", output.is_sliding);
}
High-performance empirical tire kinetics benchmarked against Unity TLabVehiclePhysics. View Full BENCHMARKS.md →
100% test coverage across all Pacejka formulas and slip kinematics.