Skip to main content
gamedev.net
🔒 Locked

ODE 2d Pixel coordinates

Started by shadowisadog Jul 11, 2006 at 1:12 AM 1 replies 1k views
Original Post
shadowisadog
shadowisadog
Hello :). I am working with ODE (Open Dynamics Engine) in C++, and I have hit a bit of a snag. I am working with ODE in 2d (Using Plane2d), and I was wondering if there is a way to use pixel coordinates instead of whatever unit it uses currently? Thanks :).
grhodes_at_work
grhodes_at_work
ODE is unitless. You can, in theory, choose any units you want for length, time, mass, and as long as the values you assign for mass/inertia tensor, forces, torques, etc., are consistent, it will work. So...you could choose your length unit to be a pixel. And if you choose to use SI units for everything else you'd have to specify your values something like:

mass = kg
length = pixel
time = second
density = kg / (pixel3)
force = kg-pixel/(second2)
velocity = pixel/second
acceleration = pixel/(second2)
torque = kg-(pixel2)/(second2)

They key.....is consistency. If you let pixels be your length unit, you cannot mix-and-match with meters or anything else. Your force values, torque values, everything will have to be built on pixels. But, it can be done with ODE proper.

One other thing you'll have to look out for, potentially. When dealing with values that have very different magnitudes, say 0.000001 and 1x1028, it is easy to lose precision when doing floating point math. For example, 1x1028 minus 0.000001 will yield exactly 1x1028 because there aren't enough bits to represent the full precision result. This can cause difficulties that are difficult to trace. And when you play around with different units types, types that may be very different from real-world units, you may very well exaggerate the precision problem.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.