Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Box2D: b2GetBodyInertia

Author
Message
DrT
18
Years of Service
User Offline
Joined: 10th May 2008
Location: 26.78 degrees North, -70.49 degrees West
Posted: 4th Aug 2010 20:07
I am assuming that b2GetBodyInertia calculates the rotational inertia (or moment of inertia) about the body's center of mass. Is this correct?

I created a thin rod using Box2D and calculated the rotational inertia - see code below.



The rotational inertia of a thin rod about its center of mass I should be I = ML^2/12, where M is the mass of the rod and L is the length of the rod. I know that this is for a linear mass distribution and I technically don't have one. However, this should be close.

1) Using this formula with kg and m, I get (1/12)*(40 kg)*(4m)^2 = 53 kgm^2.
2) Using this formula with kg and pixels, I get (1/12)*(40 kg)*(400 pixels)^2 = 533333 kgpixels^2.
3) Using b2GetBodyInertia, I get 650.

Since I used the b2SetScale command, I would expect methods 2) and 3) to agree. Unfortunately, they don't. What am I overlooking?
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 5th Aug 2010 01:02
The units of inertia are not well defined when using degrees rather than radians. For the purposes of Box2D I took inertia to be measured in kg m²/rad² as this made most sense in context.

This means that the relevant scales for angles will have been taken into account when inputting/outputting inertias.

However, inertias when using units other than radians only really make sense relative to one another.

[b]
DrT
18
Years of Service
User Offline
Joined: 10th May 2008
Location: 26.78 degrees North, -70.49 degrees West
Posted: 5th Aug 2010 01:21
I reset the scale to 1 for angular measure so that radians are in use. Now, methods 2 and 3 agree. I also confirmed this with another geometry (circle about its center). I guess I'll be working in radians from now on.

Thanks for your help.

Login to post a reply

Server time is: 2026-07-24 20:35:37
Your offset time is: 2026-07-24 20:35:37