Short version:

1.The 2500 is from the conversion factor (50) from box2d units to pixels.

2. Your equation to calculate won't work for all shapes. Instead of just mass you need to calculate the Moment of Inertia for that particular object. After that the only magic number is 0.02 or (1/50) which is the conversion factor from pixels to box2d units.

3.

AngularVelocity = Velocity / Diameter (pi)

should be:

AngularVelocity = Velocity * 180 / (radius * pi)

Long Version:

Box2d internally uses it's own distance unit (m) which is 0.02 pixels.

The conversion is:

1 [pixel] = 0.02 [m]

or

50 [pixel] = 1 [m]

The set Velocity action and getVelocity expression already do the conversion without help, but the conversion isn't considered with Force or Impulse.

Before I go any further I'd like to suggest that the mass expression is returning a bad value. The formula for mass with units is:

- Code: Select all
`Mass [d * m^2] = density [d] * area [m^2]`

Where [d*m^2] is the same as [kg]

So for a 32x32 pixel square with density 1 the mass should be:

- Code: Select all
`area [m^2]= (height [pixel] * 0.02 [m/pixel]) * (width [pixel] * 0.02 [m /pixel]) = (32 * 0.02) * (32 * 0.02) [m^2] = 0.4096 [m^2]`

mass [d * m^2] = density [d] * area [m^2] = 0.4096 [d * m^2]

But the mass expression returns 20.48 or 50 times 0.4096 which is incorrect since that makes the units [d*pixel*m].

This is only important because if it were correct you'd only have to multipy by 50 instead of 50*50 or 2500 with the Force and Impulse equations.

Torque is a bit trickier. The equation for Torque is:

- Code: Select all
`Torque [kg*m^2*deg/s^2] = inertia [kg*m^2] * ang_accel [deg/s^2]`

Inertia is calculated differently for different shapes. For a square the equation is:

- Code: Select all
`Inertia = mass * (width^2 + height^2)/12`

For mass we'll use 0.4096 and we'll need to covert height and width from [pixel] to [m] and we get:

Inertia = 0.4096 * ((32*0.02)^2 + (32*0.02)^2)/12 =~ 0.02796...

I then ran a test to apply a torque of 1 for 60 ticks. At the end the angular velocity was approximately 35.76. From that the acceleration could be calculated with acceleration=(final_speed-initial_speed)/time which ended up being 35.76.

The numbers agreed with the equation when it was plugged in:

torque = inertia * ang_accel

1 ?= 0.02796 * 35.76

1 ~= 0.9998

This link may also be useful as it predicts motion using equations much like yours.

parabola-tracjectory-tracing-with-physics-box2d_p640838?#p640838-cheers