# Does conservation of energy exist in most physics engines?

The reason I am wondering, is because while trying to create gravity around a point in the physics game I am creating, I wondered "If I create an object in the middle of the screen, where would the energy come from to allow it to fall towards the object of mass?" So this leads me to wonder, is the gravitational energy for an object created (defying the law of conservation of energy), and if so, why do objects orbiting another object not speed up to infinity?

PS: I didn't know whether or not to put this question here, or in physics, but I assume it's more applicable here. (I am also using c++ and SFML if it is important, or you want to include some source code as an example)

• I don't know if this is a good idea, or if any physics engines do this, but could I give the object a specific GPE (gravitational potential energy) at creation, so I'm only going against the laws of physics when I create the object, but it is fine for the rest of the time. This solution could be completely wrong though, because this is all based off a very vague physics GCSE. – Orfby Jan 28 '15 at 7:49
• I'm voting to close this question as off-topic because it asks about the real-life physics of instantly creating a mass at an arbitrary location in the universe. – Seth Battin Jan 29 '15 at 19:08
• @SethBattin Yes it talks about real world physics, because that is what it is based off of, it will be a physics game, I have to base it off of real life, otherwise the game wouldn't make any sense because there is no real world application. It's like saying a discussion about an FPS is off topic because it asks about how many guns there are in the world, so the developer can accurately distribute ammo and guns in the game world. – Orfby Jan 29 '15 at 21:06
• It's more like asking if Santa Claus is real because you can make a game in which he is a character. When you click to insert an object, conservation of mass is not the only law of the universe you are violating. But that has zero bearing on your physics simulation, assuming it carries on being physically accurate after you disturb it. – Seth Battin Jan 30 '15 at 6:11
• @SethBattin The problem with saying that it has "Zero bearing on my physics simulation" is that it is completely subjective, just because if you made a physics game it would break the laws of physics left right and centre, doesn't mean that my physics game can't have realistic physics. The only time I'll accept it being off topic is if I can release a question on both gamedev and physics, because then, it won't be irrelevant and I can still get people that know how physics engines work. But oh well, I have my answer now, so do what you like. – Orfby Jan 30 '15 at 6:28

## 2 Answers

It's really only the creation of an object out of thin air that violates natural law, since it's the position at which the object is created that generates GPE. All forces are entropic, which is to say (in a tremendous simplification of terms) that they cause systems to evolve toward a resting state. The more starting energy the bigger the forces, and the faster (usually) the final state is reached. It's actually change in force, the gravitational attraction between one thing and another which popped into existence, that "generates" energy.

Energy would be conserved in such a system if, say, you could only create 5 objects, and they eventually reached a final position where they orbited each other or landed, the energy would end up being retained as angular momentum. We could explain away rounding errors (which should be in favor of energy loss) as universal entropy. =P

After some rounding errors energy will be different from one step to the next.

Most physics engines just let you apply forces to objects nilly willy and don't care where the "energy" for the work it is doing would have come from and letting the programmer decide how it came about.