Physics Engine

Hey Veeky Forums, I want to make my own physics engine. What should I start learning?

Other urls found in this thread:

en.wikipedia.org/wiki/Continuum_mechanics
gamedevelopment.tutsplus.com/tutorials/how-to-create-a-custom-2d-physics-engine-the-basics-and-impulse-resolution--gamedev-6331
en.wikipedia.org/wiki/Smoothed-particle_hydrodynamics
twitter.com/SFWRedditVideos

a good place to start would be physics

1. Programming
2. Programming
3. Programming
4. The physics you want to cover

Programming. But a physics engine is a super advanced project for beginners though

Learn continuum mechanics.
en.wikipedia.org/wiki/Continuum_mechanics

Then something about numerical methods such as finite element method, finite differences and linear and nonlinear solvers.

Programming is nice, too. Test your algorithms with Numpy... Then implement in C++.

You need to know

-physics
-mathematics
-numerical analysis
-programming

If you want to play, it's really simple.
If you want to do a serious job it's a lot more complicated.

Linear algebra and differential geometry for simulating curved spaces.

I read this a while ago, and it was nice to get me started.
gamedevelopment.tutsplus.com/tutorials/how-to-create-a-custom-2d-physics-engine-the-basics-and-impulse-resolution--gamedev-6331
To be fair, it's more practice than theory.

To make that cloth stuff, all you have to do is verlet integration with harmonic potentials

Op im doing this right now.
Its hard as fuck, start off with 2d and then extend the ideas to 3d.

A good start is the book "physics for game developers 2nd edition".

In the book, when it comes to implementation, the author writes 2 pages just to talk you out of doing it because its extremly hard to do.

So dont do it if there is absolutly no other way and when you do it only do what you need and nothing more.

>don't do it because it is hard

start with programming
i recommend C for serious work and heavy lifting, and python for everything else

then you'll need some basic physics
the partial differential equation forms of newtonian mechanics is all you REALLY need to know i think
it would certainly help to get a large amount of rigid body mechanics under your belt though

the math is relatively easy, it's more programming than math honestly
you need to know how to discretize PDEs, which is a lot easier than it sounds
in general, numerical methods will help you a lot

familiarity with linear algebraic concepts is basically required, you will definitely need to know how to work with vectors and matrices

a full physics engine is obviously going to be SERIOUSLY involved, and i'm no expert in the field, but i figure that you will need a lot of programming experience to hammer out a good physics engine

but as with any project like this, i wouldn't worry about making a perfect engine at first, just familiarize yourself with the concepts needed to build one, and keep building on it

i also recommend you check out the bullet physics engine, it's open source and on github

en.wikipedia.org/wiki/Smoothed-particle_hydrodynamics

>just copy paste bullshit empirical/theoretical models with billions of assumptions
>you will get shitty bugs due to numerical methods
>pay amazon to use their cluster to simulate bouncing balls
>proceed to kys because it's a waste of time

>>don't do it because it is hard
>Waste time reinventing the wheel doing something that usually requires a variety of paid professionals working full time to ever amount to anything while you just could be using some open source engine and get to actually achieve meaningful work

There ya go.

>pay amazon to use their cluster to simulate bouncing balls

>mfw I had been running Matlab on the uni's VM for a week in order to get a 10k by 10k resolution mandelbrot

so familiar it hurts inside.
maybe I shouldn't have used their own implementation of complex numbers.

research or fun?

fun

You are probably better off writing parallel code in c/Fortran/OpenCL, and using a cluster, forget trashlab.

yeah I'll probably migrate but it's so convenient for prototyping it's hard to do it

these posts are absolutely useless. Who the fuck would have thought you need to learn programming.

you need to learn:

> any language that is called C++ and doesn't contain "Java" in its name
> OpenGL (not DirectX because it's for cucks)

The hardest part would be figuring out OpenGL for the first time. Once you get that you can start thinking about physics.

>> OpenGL (not DirectX because it's for cucks)
DirectX is the MBA chad loudly fucking the grill next door while you're masturbating to her fb page
OpenGL is (you)

call me when webDirectX is a thing

maybe your phone will be running DirectX ES

The physics engine has nothing to do with the graphics API you'll use.
Very often if doesn't even need to be run real-time.

c++ is a fair choice but java would be great too.
just avoid scripting languages such as Python, because they're slow.

how are you going to debug a physics engine with no visual output?

> printf("[%f,%f],[%f,%f]\n",testobj1.getx(),testobj1.gety(),testobj2.getx(),testobj2.gety());

good luck

there should be nothing to debug in a physics engine.

If you wanted you could visualize the data on third party software anyway.

>there should be nothing to debug in a physics engine.
t. Bethesda softworks employee

> write a physics engine and then just never run it
> use some shitty abstraction that is not even comparable in scope or optimization as OpenGL
> "trust me man, JFC/Swing is a great visualization tool for your physics engine"

kill yourself my man

Actual guy who has coded a physics engine here. Don't bother with java.

Start, if you're so inclined with a 2d engine. Maybe SFML is a good choice as it provides the simple rendering shit you'll need to get your foot in the door. Begin creating a box2d engine. Implement the forces, friction and collision interpolation in 2d. Once you have a simple 2d implementation working, take your 2d engine and extrapolate it to three dimensions, switch your renderer to something you built in openGL or use whatever free renderer you like.

A physics engine is not something you want to be doing as your first project. Learn your chosen language and get highly competent with it first.

Pic related is a code snippet with some of the math you'll probably need, it's in C# and a super shitty implementation and a version that's missing a lot, but yeah. Good luck.

I've written full blown rigid body simulators and fluid simulators and let me tell you OP this shit isn't easy. I would never call anything i've done an "engine".
As said : "If you want to play its simple". And to be frank, it really is. Just know basic calculus, some physics and arm yourself with an entry level physics book and you can do a lot. If you want to do something commercial ,well, the difficulty curve skyrockets.

Dealing with problems like:
>stacking
>tunneling
>numerical stability
>choosing an acceleration structure
>choosing a friction model

were a nightmare for me. Dont get me wrong, coding for physics is fun, but you will most likely only make physics 'toys' , not engines.