Unit systems
A question I've heard a few times now is 'what units does ExtremePhysics use'.
ExtremePhysics can use any unit system as long as it's consistent. SI units (meter, kilogram, second) are fine, but (pixel, kilogram, second) of (pixel, kilogram, step) works just as well. You just have to remember to be consistent: if you use (pixel, kilogram, step), the unit of speed is pixels per step, the unit of density is kilogram per square pixel, the unit of force is kilogram times pixel per step squared, ...
The units for distance, mass and time are the base units, you can convert any other unit you will need to a combination of those. You can find the full list for SI units here.
If you want to make the game as realistic as possible (e.g. using standard gravity, 9.81 m/s2), it's probably easier to use (meter, kilogram, second) and remember that (e.g.) meter = 50 pixels and second = 30 steps. In this case you should set 'timestep' to 1/30 with ep_world_settings. You also have to find a way to scale everything, either by using views, or manually with draw_sprite_ext (ep_debugdraw_set_transformation can also help). If you don't really care, (pixel, kilogram, step) is probably better for you.
Yes, you can also use inches, feet, miles, pounds, ... as long as you're consistent. However, for numerical reasons it's not a good idea to use units that are very small or very large compared to the thing you're simulating. So don't use meters if you're simulating the solar system. As a rule of thumb, if any of your numbers is greater than 10000 or less than 0.0001, you're probably using the wrong unit.
Comments
Dark_master4 |
Comment #1: Thu, 8 Mar 2012, 20:06 (GMT+1, DST) Well that's all good, but even with that information I'm unable to set it to react like reality. I've made a constant called GRAVITY and set it to 9.81 (I suspect that of being in pixels per second² at base, so I also tried 313.6 pixels per second²) The questions should be straight forward: Edit: Last modified: Thu, 8 Mar 2012, 20:34 (GMT+1, DST) |
Maarten BaertAdministrator |
Comment #2: Sun, 11 Mar 2012, 19:52 (GMT+1, DST) @Dark_master4: You missed the scaling part. Unless 1 pixel in your game equals 1 meter, you have to find a way to scale everything. You could use views for that, or do it manually with draw_sprite_ext. If you want to avoid that, just stick with (pixel, kilogram, step) and convert all your values to these units. Let's say in your game 50 pixels = 1 meter and 30 steps = 1 second. Gravity: Density: |
Dark_master4 |
Comment #3: Tue, 13 Mar 2012, 23:15 (GMT+1, DST) Got it. Very helpful. |