Skip to content

Ordinary Differential Equations (ODE) solvers for particle physics in Unity

License

Notifications You must be signed in to change notification settings

akihiko47/ODE-solvers-for-particle-physics-in-Unity

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧮 ODE solvers for particle systems 🧮

banner

In this repository, I have implemented some Ordinary Differential Equations (ODE) solvers and cloth particle system that use them. They basically do something like this:

formula

formula

X is a vector that contains all particle's positions and velocities. The job of ODE solvers is to update this vector at every small time step. To do this they need function that returns derivative at needed moment of time. This function can be found at ParticleSystem class as well as X vector. Simple example of how this configuration can be used in Update() method: stepper.takeStep(system, Time.deltaTime);. stepper is an instace of some ODE solver class and system is an instance of Particle system descendant. With positions information you can draw particles and generate meshes.

Solvers ➖

The ODEsolvers file contains 3 classes. They all realize ODEsolver interface.

  1. ExplicitEuler - high speed, low precision
  2. Trapezoidal - medium speed, medium precision
  3. RungeKutta4 - low speed, high precision

Installation 🔧

There are 2 ways:

  • import ParticleSystems.unitypackage via Assets-Import Package
  • clone/download this repository and move the Assets/Scripts/ParticleSystems folder to your Unity project's Assets folder

Usage ➕

I've only presented two use cases: pendulum and cloth physics. But this system can be extended to:

  1. Cables
  2. Hair
  3. Sof-body
  4. Liquids

It's worth noting that computing now takes place on the CPU. For full utilization I should move the calculations to the GPU 🥴

Based on 🖌️

  1. this lecture
  2. this lecture
  3. assignment description

Thank you for reading this 😊!