Efficient 3D Physics Simulation with Gravity and Collisions
100 likes | 168 Vues
Explore equations, gravity, Euler's method, collisions, efficiency, and applications in this 3D physics simulation. Learn the concepts and strategies for accurate and optimized simulations.
Efficient 3D Physics Simulation with Gravity and Collisions
E N D
Presentation Transcript
Steven Durant 3D Physics Simulation
Contents • Equations • Gravity • Euler’s Method • Simple Collisions • Correct Collisions • Efficiency • Applications • Screenshots
Gravity • F = G * M1 * M2 / R2 • Unavoidable efficiency of O(n2)
Euler’s Method • a = F / M • ∆v = a * ∆t • ∆p = v * ∆t
Simple (Elastic) Collisions • Check for collision via particle radius • Conservation of momentum • v1’ = v2 * M2 / M1 • v2’ = v1 * M1 / M2 • This method is flawed
Correct Collisions • Find next collision based on time • O(n2) • Find distance between particles • Find distance moved into each other ∆d ∆D
Correct Collisions • Find fraction of timestep until collision ∆t = 1 – ( ∆d / ∆D ) • Move both particles for the fraction • Use ∆t in Euler’s Equations • Calculate new velocities • Use conservation of momentum • Move both particles for the other fraction • Use (1-∆t) in Euler’s Equations
Efficiency • Pruning pairs of particles • Pairs moving away from each other. • Pairs too far apart. • Pretend their velocities are towards each other • If they still won’t collide before the nearest collision then their real velocities don’t need to be used or checked.
Application • Find out how long it would take for two apples on a frictionless table to collide by using realistic masses for the apples. • Put thousands of tiny little masses along a random distribution and see what the end product is. • Stuff orbiting each other? • One big blob?