/home/aluo/school/PHYS3266/softie.html

# Softie 2D

Andrew Luo

A simple soft-body physics simulation

No support for HTML canvas

The following is a Javascript implementation of the particle spring-mass model, which can be used to investigate the dynamics of a soft-body and soft-body interactions with obstacles..

F=kxF = -kx

This simulation is based off of Gonkee's excellent [But How DO Soft Body Simulations Work?] video.

Click to stimulate some velocity on a particle of the soft-body

Press 'e' to randomly simulate a mass particle

# Parameters


# Obstacles




# Refresher on Basic Geometry

# How It Works

  1. Similar to how atoms form a lattice structure in nature, the structure of a soft-body is composed of point masses attached to other point masses by springs according to 8-adjacency
  2. The triangles in the soft-body create a stable structure.
  3. All the mass points of the system are stored in a sequential array as objects.
  4. In each frame, the velocities and positions are calculated using the simple Euler's method.
    • velocity+=Fdtmvelocity += \frac{F * dt}{m}
    • position+=velocitydtposition += velocity * dt
  5. To test collisions with polygon obstacles, a technique called ray casting is used.
    • A beam (arbitrarily chosen from the right) is sent to the point, and the number of intersections with polygon edges is counted.
    • If the number of intersections is even, then the point is not inside the polygon
    • If the number of intersections is odd, then the point is inside the polygon
    • If point is inside polygon, push point out to closest point on edge, then reflect velocity off the normal.

# Reflection