2D Bridge Simulation Demo

Physics Engine Foundation

The bridge simulation employs a mass-spring system. Each bridge component is modeled as:

  • Particles: Mass points with position/velocity attributes (mass, position, velocity)
  • Springs: Constraint elements connecting particles using Hooke's Law
  • Road Beams: Special springs marked for vehicle interaction

Core Mathematical Models

1. Spring Dynamics: Governed by Hooke's Law:

Spring Force = (Stiffness Coefficient) × (Direction Vector) × (Current Length - Rest Length)

Where:
- Stiffness Coefficient (α) determines spring rigidity
- Direction Vector points between connected particles
- Rest Length (L) is the spring's unstretched length

2. Force Integration: Uses implicit Euler method:

New Velocity = Current Velocity + (Total Force / Mass) × Time Step

New Position = Current Position + New Velocity × Time Step

Step Function Breakdown

Phase 1: Force Accumulation

Gravity is applied to all movable particles. Vehicle forces distribute to nearest road beam particles using weighted position calculations.

Phase 2: Vehicle-Beam Collision and Reaction

Handles real-time interaction between vehicles and road surfaces:

  • Beam Selection:
    • Iterates through springs marked as road beams
    • Skips non-road structural elements (towers/cables)
  • Projection Calculation:
    • AB = Beam endpoint vector (B - A)
    • t = (VehiclePosition · AB) / ||AB||² (dot product ratio)
    • Clamps t between 0-1 to ensure on-beam projection
  • Collision Detection:
    • Calculates closest point: Closest = A + t*AB
    • Measures vehicle-to-beam distance: ||VehiclePos - Closest||
    • Compares against vehicle radius for penetration
  • Collision Response:
    • Position Correction: Moves vehicle to beam surface
    • Velocity Adjustment: Removes beam-penetrating velocity
    • Normal vector calculation for directional response

Phase 3: Spring Network Processing/Resolution

Spring forces calculate in both directions, respecting fixed particles. Road beams receive extra downward forces from vehicle weights.

Phase 4: Spring reaction to high force (splitting)

Springs breaking point: (Current Length - Rest Length) / Rest Length > Threshold
Broken springs split into two segments with new midpoint particles

Phase 5: Integration (implicit Euler)

States update and all forces reset after calculation cycle.

Other Features

  • Thread-Safe Updates: Parallel processing protection during spring breaks
  • Presets: Pre-built bridge designs with unique force patterns




Back to Projects