# A working physics engine package?

**URL:** https://discourse.julialang.org/t/a-working-physics-engine-package/48184
**Category:** General Usage
**Tags:** package, physics
**Created:** [October 11, 2020, 10:15pm UTC](https://discourse.julialang.org/t/a-working-physics-engine-package/48184 "2020-10-11T22:15:13Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![mlg556](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlg556/32/18588_2.png) [@mlg556](https://discourse.julialang.org/u/mlg556)
#### Post date: [October 11, 2020, 10:15pm UTC](https://discourse.julialang.org/t/a-working-physics-engine-package/48184/1 "2020-10-11T22:15:13Z")

</div>

I’ve been trying to find a working physics engine library, but it seems that the ports of [Box2D](https://github.com/zenna/Box2D.jl) and [Chipmunk](https://github.com/zyedidia/Chipmunk.jl) are out of date. There is RigidBodyDynamics, but as far as I can tell it doesn’t support collisions and contacts? I know that Julia is not really used in game development, but I would like to simulate a few boxes colliding with each other. It seems interesting to me that there are multiple quantum physics and nonlinear dynamics packages, but not a meager box2d 😃

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [October 11, 2020, 10:53pm UTC](https://discourse.julialang.org/t/a-working-physics-engine-package/48184/2 "2020-10-11T22:53:13Z")

</div>

> [@mlg556](#):
>
> I know that Julia is not really used in game development, but I would like to simulate a few boxes colliding with each other.

I mean, you’d just call a differential equation library for things like that.

---

<div class="post-metadata">

### Author: ![anon92994695](https://avatars.discourse-cdn.com/v4/letter/a/ce7236/32.png) [@anon92994695](https://discourse.julialang.org/u/anon92994695)
#### Post date: [October 11, 2020, 10:59pm UTC](https://discourse.julialang.org/t/a-working-physics-engine-package/48184/3 "2020-10-11T22:59:40Z")

</div>

Writing your own Box2D wouldn’t be difficult. 🙂 I have a handful of routines that would be useful for that. But I bet there’s a lot of the functionality buried in the geometry and otherwise packages. Might take a little prodding.

---

<div class="post-metadata">

### Author: ![mlg556](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlg556/32/18588_2.png) [@mlg556](https://discourse.julialang.org/u/mlg556)
#### Post date: [October 12, 2020, 12:38am UTC](https://discourse.julialang.org/t/a-working-physics-engine-package/48184/4 "2020-10-12T00:38:15Z")

</div>

well that was just an example actually, surely a complete physics engine with constraints, joints and continous collisions is not readily doable with differential equations?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [October 12, 2020, 1:18am UTC](https://discourse.julialang.org/t/a-working-physics-engine-package/48184/5 "2020-10-12T01:18:20Z")

</div>

No, that was an example of a domain specific differential equation solver… this is literally just DAEs with events, which is how it’s normally done in the large-scale frameworks.

Anyways. The ones that I know about so far are RigidBodySim.jl

[https://github.com/JuliaRobotics/RigidBodySim.jl](https://github.com/JuliaRobotics/RigidBodySim.jl)

or Modia3D.jl:

[https://github.com/ModiaSim/Modia3D.jl](https://github.com/ModiaSim/Modia3D.jl)

Both of which just build calls to differential equation solvers of course. Both do contacts of course, since that’s just a differential algebraic equation. I know Modia does collusion handling and I’m not sure if RigidBodySim.jl does but you’d just write a standard DifferentialEquations.jl callback to add it to the library so it wouldn’t be hard to add.

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [October 12, 2020, 1:18am UTC](https://discourse.julialang.org/t/a-working-physics-engine-package/48184/6 "2020-10-12T01:18:22Z")

</div>

When you say physics engine, do you mean a “game physics” engine, or “real physics” engine?  
And what sort of engine: from some remarks I take it it is Newtonian dynamics?

What exactly would you like to accomplish?

---

<div class="post-metadata">

### Author: ![Orbots](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/orbots/32/3392_2.png) [@Orbots](https://discourse.julialang.org/u/Orbots)
#### Post date: [October 23, 2020, 10:46pm UTC](https://discourse.julialang.org/t/a-working-physics-engine-package/48184/7 "2020-10-23T22:46:20Z")

</div>

Since they mentioned Box2d, they are looking for a “game physics” engine.

Which means it focuses on simulating large numbers of convex objects in collision with friction at hyper real-time rates. \< 16ms sim time for thousands of bodies. Typically the differential equation part of it is trivial, you just use symplectic Euler, which is a couple of lines of code.

I’ve looked for one, but haven’t found anything.

---

<div class="post-metadata">

### Author: ![mlg556](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlg556/32/18588_2.png) [@mlg556](https://discourse.julialang.org/u/mlg556)
#### Post date: [October 30, 2020, 9:23pm UTC](https://discourse.julialang.org/t/a-working-physics-engine-package/48184/8 "2020-10-30T21:23:37Z")

</div>

Just to further clarify “physics engine”, here is a brief explanation from Box2D wikipedia page:

> Box2D performs constrained rigid body simulation. It can simulate bodies composed of convex polygons, circles, and edge shapes. Bodies are joined together with joints and acted upon by forces. The engine also applies gravity, friction, and restitution.

---

<div class="post-metadata">

### Author: ![Orbots](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/orbots/32/3392_2.png) [@Orbots](https://discourse.julialang.org/u/Orbots)
#### Post date: [October 31, 2020, 3:20am UTC](https://discourse.julialang.org/t/a-working-physics-engine-package/48184/9 "2020-10-31T03:20:09Z")

</div>

Are you just looking for a 2D ( games ) physics engine?  
(or N-dimensional [Marc ten Bosch - N-Dimensional Rigid Body Dynamics](https://marctenbosch.com/ndphysics))

I’m slowly working a 3D one, but my time is limited, so might be awhile before it’s useful. There is some overlap for the algorithms you’d choose for 2D and 3D, but efficient collision detection, angular constraints and visualization are totally different for the two. But hey, multiple dispatch!
