How to program a physics simulation?

I am trying to create a Java package that can be used to write simulation programs. My goal is to create โ€œobjectsโ€ such as springs or solid objects such as cubes and spheres. They will have mass, speed, gravity, etc., and they can interact with each other.

I saw some modeling programs at www.myphysicslab.com , but my problem is that I donโ€™t want to write different equations for different senaria. Is there any way to do this? I am new to programming.

+6
source share
4 answers

Creating a physical mechanism is difficult. (Very difficult). But it can also be a lot of fun. Well, fun in "Why am I doing this with myself?" kind of way.

Assuming you have a fair understanding of the math involved *, and assuming you are interested in the dynamics of a rigid body, there are a few classic references to start with:

These are good places to start and will provide you with more than enough for you.

You can also watch Box2D Erin Catto and related GDC tutorials that you can download.

For more specific help, Bullet forums also contain a section where you can discuss and ask questions as soon as you understand some basics.

* If you do not have this honest understanding, find out. If you do not want, do not try to use an existing engine. If this is your first programming experience, focus on programming first. Do not overload.

Good luck.

+21
source

To understand physics, you must first understand math. Trying to write a physics engine without using mathematical equations is to make a cake without ingredients.

The whole career is built on the creation of physical engines, so I advise you to either use the existing engine or get your books.

+6
source

Building a physical simulator can be a lot of work. Two dimensions are much simpler than three, so maybe you want to start with 2D. You might want to start with an existing package such as JBox2D . It has a constraint resolver, friction, etc. You can build on top of JBox2D or learn how it works.

HTML5 version available with online demo: GWTBox2D

+1
source

There is a program called Easy Java Simulations that does exactly what you want! You can create Java applets and prepare many visual objects. You can also write java code and routines.

visit http://fem.um.es/Ejs/ for download.

0
source

Source: https://habr.com/ru/post/892909/


All Articles