Inverse in Chipmunk

Official forum for the Chipmunk2D Physics Library.

Inverse in Chipmunk

Postby KMagic » Mon Sep 01, 2014 12:49 am

I am new to game programming as well as Chipmunk. I have a simple question:
What do m_inv ( inverse of mass) and i_inv (inverse of moment of inertia) mean? 8-)
Posts: 1
Joined: Mon Sep 01, 2014 12:43 am

Re: Inverse in Chipmunk

Postby slembcke » Tue Sep 02, 2014 1:08 pm

On most older CPUs, floating point division is very expensive compared to multiplication. So for a something like mass where you almost always use it as var/mass, it's better to precalculate m_inv = 1/mass so you can do var*m_inv instead.

It's quite possible that in the last 8 (!) years that it's no longer a relevant optimization though. Haven't bothered to check in a long time.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! ->
User avatar
Site Admin
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 1 guest