1

I'm trying to build a 2D physics engine (rigid body dynamics simulation) in C#. So far I have simulated boxes (squares) of different sizes which are fixed in position but can rotate around their centroids (centre of mass) when a force is applied to them. This is the Box.ApplyForce() method that is called when a force is applied:

    public void ApplyForce(double x, double y, Vector force)
    {
        //angular acceleration = torque(angular force) / moment of inertia
        Force tempForce = new Force(x, y, force.X, force.Y);
        forceList.Add(tempForce);

        Vector displacement = new Vector(x, y);

        double torque = displacement.X * tempForce.yForce - displacement.Y * tempForce.xForce;

        double momentOfInertia = (mass*(size*size*2))/12;

        angularAcceleration += torque / momentOfInertia;
    }

Now this seems to be working correctly so far, but I now need to include translational acceleration in my simulation so my question is: what happens when you apply force to the edge (or any non-centre-of-mass point) of the object? Will the translational acceleration be the same as if it were applied to the centre of mass?

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
Toxic Tom
  • 174
  • 12
  • 5
    Isn't this a physics question, more than a programming one? – ryanwebjackson Jun 26 '18 at 13:25
  • I would suggest you have a look on https://physics.stackexchange.com/ – Liam Jun 26 '18 at 13:26
  • 5
    I'm voting to close this question as off-topic because it is a physics question and not a programming one. – Liam Jun 26 '18 at 13:30
  • To answer your question: yes, the translational acceleration for a force applied anywhere on the body will be the same as if it were applied to the centre of mass. – EvilTak Jun 28 '18 at 06:09

1 Answers1

0

Are these simulated squares on a flat surface when simulating translational motion? Can they rotate when the force is applied, and also move translational?

If the box is on a flat surface it cannot rotate when you are simulating translation acceleration it does not matter where the force is applied. It just matters the angle at which the force is applied, or the component of the force vector in the direction of the translational motion. The component of the vector perpendicular to surface will affect the magnitude of the normal force, which will affect the frictional force if that is something you are taking into consideration.

If the box is not on a surface and just floating in space when the force is applied the answer gets a bit more complicated. Maybe clarify what you are simulating a bit more.

user9964422
  • 119
  • 3
  • 15