Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am wondering if someone has an elegant way of calculating the following scenario.

I have an object of (n) number of squares, random shapes, but we will pretend they are all rectangles.

We are dealing with no gravity, so consider the object in space, from a top down perspective. I am applying a force to the object at a specific square (as illustrated below).

Applying a force

How do I calculate the rotational angle, based on the force being applied, at the location being applied. If applied in the center square, it would go straight. How should it behave the further I move from the center? How do I calculate the rotational velocity?

What do you want to happen to the force through time as the object rotates? Does it always apply to the same square in the same direction? Does it "sweep" along the edge of the object? With the information you are giving, you can only get the corresponding rotational force (aka. torque) but if you want to deduce a rotation speed from that, you'll need to either provide an impulse (rather than a force) or explain how the force should be applied as time goes. –  sam hocevar Nov 10 '11 at 21:27
Honestly this would probably be a better question for physics.stackexchange.com, as this is entirely a question of basic mechanics. –  BlueRaja - Danny Pflughoeft Nov 10 '11 at 22:54

2 Answers 2

up vote 36 down vote accepted

You're trying to calculate the Torque. Torque depends on the applied force F, the point of application, and the center of mass of the object.

1) Center of Mass. Define the center of mass of the object.

2) Point of Application: Define the point at which the force acts on.

3) Moment Arm: The distance between the two points defined above.

Point centerofMass
Point applicationPoint
Vector momentArm = applicationPoint - centerofMass

4) Angular force: Divide your force F into two orthogonal vectors, one Parallel to the line in 3) and one Perpendicular. The parallel component does not affect angular momentum. The perpendicular one does. You can calculate the parallel component by vector projection. You can subtract that from the original to get the perpendicular component. In pseudocode (dot means dot-product)

Vector myForce
Vector momentArm

parallelComponent = momentArm * (dot(myForce, momentArm) / dot(momentArm, momentArm))
angularForce = myForce - parallelComponent

5) Torque: The perpendicular component of the force multiplied by the length of the moment arm.

Vector angularForce
Vector torque = angularForce * momentArm.Length

To get from Torque to angular velocity:

1) Moment of Inertia: A definition of how much rotational inertia a given object has. For example, it takes more torque to rotate a long bar than a sphere of the same mass. If you aren't concerned about realism, you can pretend the moment of inertia is relative to the mass, or you could ignore the shape and mass of the object entirely.

2) Angular acceleration: Torque / Moment of Inertia yields Angular Acceleration

3) Angular Velocity: The Angular velocity will keep increasing as long as torque is being applied. So a formula will roughly be "Angular Velocity at time T is the cumulative sum of Angular acceleration up until T." This is expressed in pseudocode as

void Update(float elapsedSeconds):
    orientation += 0.5 * angularVelocity * elapsedSeconds;
    angularVelocity += angularAcceleration * elapsedSeconds;
    orientation += 0.5 * angularVelocity * elapsedSeconds;
Great information, however, the part that I am the most unclear with is how to determine what the torque force should be. I have all of the components in place as you have described. –  Jon Nov 10 '11 at 20:38
@Jon: you have the components, meaning you have steps 1 - 3 and can't figure out how to calculate step 4? That's primarily the tricky step. I'll add a bit more detail there. –  Jimmy Nov 10 '11 at 20:39
+1, nice breakdown of the relevant points. –  Arcane Engineer Nov 10 '11 at 21:14
Orientation being the cumulative sum of angular velocity, orientation += angularVelocity * elapsedSeconds is wrong because it overestimates velocity over the time step, meaning that different framerates will give different orientations. A proper formula would be: float oldVelocity = angularVelocity; angularVelocity += angularAcceleration * elapsedSeconds; orientation += 0.5f * (angularVelocity + oldVelocity) * elapsedSeconds;. Also, since there is no gravity, I suggest using “centre of mass” instead. +1 for the very good explanation though. –  sam hocevar Nov 11 '11 at 12:29
Part of the perpendicular force will act to accelerate the center of mass, and as the force is applied closer to the center of mass, this factor increases. The answer is good and very clear, but it seems to be incomplete in this regard. –  Sam Watkins May 11 at 7:50

if forces are not too strong it's much more easier to simulate rotation using multiple dots and springs connecting them. in that case you just assume your shape in consist of multiple dots connected by springs. each dot represent mass and every thing else in shape has mass equal to zero.

spring & dots

in above picture black point represent masses and red line represent springs. then to apply the force you just have to apply it to the nearest dot and you'll see your object will rotate just as you like. to make your shape look like a solid structure it's better to define springs with a high damping value and high k value.


Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.