
#1
Oct2609, 08:32 AM

P: 13

I am trying to code a 2D rigid body physics engine in Java, and I am having some trouble figuring out how an object will move and rotate if the force is offcenter.
Basically, what I can't seem to figure out is a way to find out the x, y, and rotational acceleration when a force is applied at an arbitrary point on an arbitrary polygon. I tried searching, but there were only something like 23 relavent results, and I couldn't really understand them well. 



#2
Oct2609, 11:05 AM

P: 3,551

http://en.wikipedia.org/wiki/Newton%...27s_second_law Angular: http://en.wikipedia.org/wiki/Angular...ions_of_motion Both accelerations happen. 



#3
Oct2609, 11:32 AM

P: 13

I found this:
http://en.wikipedia.org/wiki/File:To..._and_force.svg So from this I understand that if the force is all parallel, then there is no rotation and all acceleration is linear, and if it is all perpendicular, then the linear/angular ratio depends somehow on the mass, mass distribution, and how far from the center of mass the force is applied. 



#4
Oct2609, 05:05 PM

P: 13

Formula/Algorithm to apply force to an arbitrary point on a polygon
So I made it that only the component of the force vector that is parallel with the coener of mass causes linear acceleration.
But I still don't know how to tell the ratio of linear to angular acceleration caused by the perpendicular component, and how to know how much torque is produced. 



#5
Oct2609, 05:36 PM

P: 3,551





#6
Oct2609, 08:01 PM

P: 13

Then how do you explain this?




#7
Oct2709, 06:58 AM

P: 3,551





#8
Oct2709, 07:32 AM

P: 13

So, for example, if I have a circular object, and I apply a force right on the edge (like a tangent on the egde of the circle), will that apply just as much linear acceleration as pushing the circle right in the middle?




#9
Oct2709, 07:49 AM

P: 14

When you apply a force to an object, be it a polygon or otherwise, you do two calculations:
1. Apply the force to the centerofgravity (COG) 2. Take the cross product of the radius to the point of application, with the force, to obtain the torque Why, you might ask? Think of the object as a system of separate particles. When you apply a force to a particle that is offset from the COG (of the system!), immediately that particle wants to tug away at F / (mass of the particle). However, since it's linked to all the other particles in your object, you get this system of internal forces  the particle pulls on the system, and the system pulls back. Your input force is therefore distributed to all the particles in the system, through their constraints. The rotation is a totally different game. It's the effect that your force has on the orientation of the system  but torqueinduced rotation is caused entirely by INTERNAL forces. Thus, if you start dividing your torque into perpendicular/parallel components, you're actually throwing away some of the input force. 



#10
Oct2709, 07:55 AM

P: 3,551





#11
Oct2709, 08:05 AM

P: 13

But my Vector class is 2D, but it appears that the cross product must be 3D. But when to think of it, only the Z axis could be perpendicular to the x, y plane, so can I just calculate the Z axis and ignore X and Y?
And how exactly do you convert a 3D vector into a scalar rotation value? 



#12
Oct2709, 11:13 AM

P: 3,551





#13
Oct2709, 11:45 AM

P: 13

I am still wondering if this is all correct, because if I apply force to the edge of an object in my simulation, it accelerates sideways, but hardly spins at all. This is nothing like what I observe in real life or this applet:
http://www.myphysicslab.com/collision.html And these are my formulas: velocity = velocity.add(force.scale(1/mass)) dt += offset.crossProduct(force) / momentOfInertia (dt is the angular velocity, in radians per second) 



#14
Oct2709, 11:50 AM

P: 3,551





#15
Oct2709, 12:06 PM

P: 13

I figured out the problem, I forgot to convert meters to pixels and seconds to frames in a few places.
Now the simulation feels much more correct. 



#16
Oct2709, 03:43 PM

P: 13

Now I need to implement bouncing off the walls...



Register to reply 
Related Discussions  
Calculating dr/dtheta at an arbitrary point and angle  Calculus  3  
Please help to Find coordinates of a point formula Angle,Distance & first point known  Differential Geometry  3  
Finite element result in arbitrary point  Mechanical Engineering  1  
is there a formula I can apply in this case?  Introductory Physics Homework  1 