Archived

This topic is now archived and is closed to further replies.

Fusi0n

mass, forces and angular acceleration

Recommended Posts

hi all, im in the process of getting down some sort of physics framework at the moment but have kinda got stuck at the first hurdle im trying to define a mass class that will hopefully be the basis of all my objects. what im trying todo is figure out how a mass will react to a force applied upon it. by react i mean what accelerations will result from a force applied to a point relative to the center of the mass. maybe if i define my mass class i can clarify things a bit:
//-----------------------------------------------------------------------------
CMass : public CObject3D{
	public:
		//-------------------------------------
		float f_mass;
		CVector3D v_center_of_mass;
		CVector3D v_location;
		CVector3D v_velocity;
		CVector3D v_acceleration;
		CVector3D v_angular_location; // will be quat
		CVector3D v_angular_velocity;
		CVector3D v_angular_acceleration;
		//-------------------------------------
		CMass();
		CMass(float pf_mass, CVector3D *pv_center_of_mass);
		~CMass();
		//-------------------------------------
		void ApplyForce(CVector3D *pv_force, CVector3D *pv_application_point);
		//-------------------------------------
		void Update(float pf_time);
		void Render();
		//-------------------------------------
	};
//-----------------------------------------------------------------------------
 
does that look ok? thats how im defining it so far. the problem i have run into is with implementing the ApplyForce function. as you can see it takes in two vectors, one is the force (in newtons) being applied, and the other is the point relative to the center of mass that the force is being applied at. as i understand it, if we apply a force at the center of mass, this will result in acceleration of the mass in the direction of the force, depending on the size of the mass (a=f/m), with no resulting angular acceleration. also, if the application point shares an axis with the center of mass (ie one of its components is 0) and the direction of the force being applied at that point is the same as the direction of the axis, then this should result in acceleration along that axis, also with no resulting angular acceleration. but what if the application point is not the center of mass and doesnt share an axis with the center of mass, or the force does not act in the same direction as the axis on which the application force lies? in this case the resulting acceleration must depend on the vector (direction and magnitude) of the application point to the center of mass as well as the vector (direction and magnitude) of the force. not only that but this must also produce some angular acceleration depending on the same factors. as the force cannot disappear, the force resulting in acceleration of the mass and the force resulting in the angular acceleration of the mass must sum to equal the force being applied at the application point. at this point i ask: is what ive said so far correct? if not, what is the correct way this works? my question is this: how do i figure out how much of the force results in angular acceleration and normal acceleration using the force vector and the application point? someone advised me to look into cross/dot products, but i fail to understand how to apply them to this problem :s please set me straight on my thoughts and thankyou for taking the time read this rather lengthly post "We are what we repeatedly do. Excellence, then, is not an act, but a habit." - Aristotle

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
3d rotation requires a good deal of math. This might help:
http://www.d6.com/users/checker/dynamics.htm
It has lots of good information on computer simulation of physics.

You won''t get very far in making your own physics simulation unless you understand all the math behind it. So, if it is new to you, then take your time. It is lots of fun once it is working right, although some bugs are fun to see while developing it.

Share this post


Link to post
Share on other sites
wow, thanks for the link, a great deal of useful information there

however... it has forced me to question how forces act on bodies in the real world. the equations presented in the pdf''s on that site resolve the angular and linear accelerations independant of one another, is this the way it works in the real world? i was under the impression that the applied force is divided between the angular and linear accelerations.

the links to the demos on the site are very nice, i see euler integration is used with a fixed time step, maybe using verlett would be a ''better'' solution but i digress. the collision repsonse in the demos seems a little strange to me, the overall direction of motion doesnt appear to be affected by the point of contact or the angular velocity (i could be wrong, im severly sleep deprived).

so going back to my question above, shouldnt the point of application of the contact response force affect the direction of motion as well as the angular velocity? for example (look at the 3d demo on that page), if you drop a rotating cube to the ground and one of its corners hits first, would this not affect the direction of motion? in the 3d demo it appears it does not (if the cubes/rectangles have no x/y velocity components (taking z to be up/down) but do have angular velocities, they just seem to bounce along the z axis, with their angular velocity changing but with no change in the x/y components of their motion).

another example:

take a stationary cube with its center of mass to be in the center of the cube, and apply a constant force to one edge; you would expect the cube to not only rotate about the center of mass but also move, not in the direction of the force, but in an arc like motion. if the applied force is not a constant one but instead an impulse force, the resulting linear motion would not be in the same direction of the impulse force surely? or am i way off?

dont get me wrong, those pdf''s are great and have cleared up a lot of questions, but im lacking a certain clarity when it comes to how the angular velocity and linear velocity are related in terms of a contact force.

any feedback is very welcome thanks

and now i must sleep

"We are what we repeatedly do. Excellence, then, is not an act, but a habit." - Aristotle

Share this post


Link to post
Share on other sites
Yes the interaction between angular and ''normal'' forces and accelerations is a little weird. You can test it yourself that if you hit something hard at a weird angle, it both rotates and translates. I think the key to figuring it out is the same as in a normal collision though - you must conserve momentum and energy, both angular and translational. Unfortunately in 3D you have a 3x3 moment of inertia tensor and all that fun stuff. This is bringing back horrible memories of mechanics class!

Share this post


Link to post
Share on other sites
right, having slept on this (i actually wake up with answers sometimes) i have deducted that the demos on that page do not apply the response force to the point of contact, but to the center of mass, in effect just flipping the z component of the force affecting the object, hence no movement in any of the other axis.

ill take a look at the source code now and see if i can understand (im not very good and reading code ;s)

"We are what we repeatedly do. Excellence, then, is not an act, but a habit." - Aristotle

Share this post


Link to post
Share on other sites
ok then, i didnt end up looking at the code, instead i got out my pencil and paper and decided to use my own brain power to figure it out, and this is what ive come up with so far:

we have a point P which is relative to the center of mass CM. a force F is applied at P. to figure out how much of this force results in angular and linear acceleration we must define F in terms of the vector P->CM and the vector perpendicular to P->CM, which we will call P->CM_|_. the amount of force acting in the direction of P->CM produces our linear acceleration and the amount of force in the direction of P->CM_|_ results in angular acceleration. heres an ascii diagram to help explain:


_CM
\ ./|
\ ./
\ ./ P->CM
\ ./
\/\./
------>\/P
F \
\
\ P->CM_|_
\
\|
¯

(sorry, im not very good with ascii art - [link]http://www.cloudfusion.com/math.jpg[/link] - the top left doodle depicts the same diagram and is a bit more readable).

so, now the problem is how do we go about defining F, which is in world space co-ordinates, in terms of P->CM and P->CM_|_. im sure this will require some sort of sin/cos stuff, not exactly sure at the moment, im still trying to figure out if what i suggested above is indeed correct.

feedback is welcome thanks

"We are what we repeatedly do. Excellence, then, is not an act, but a habit." - Aristotle

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Fusi0n
.... i have deducted that the demos on that page do not apply the response force to the point of contact, but to the center of mass...


Actually, that is how it is done. It seems strange at first, but consider an object that cannot rotate. It will just accelerate in the direction of the force regardless of where it is applied.


If you look at http://www-2.cs.cmu.edu/afs/cs/user/baraff/www/pbm/rigid1.pdf
on page 28, at "5.5 Force vs. Torque Puzzle"
There is a very good example of how it works, and why.


When you have time, Read all of these, too.
http://www-2.cs.cmu.edu/afs/cs/user/baraff/www/pbm/pbm.html

Share this post


Link to post
Share on other sites
now im really confused, so is what i just posted completely wrong :? thanks for links, reading now

"We are what we repeatedly do. Excellence, then, is not an act, but a habit." - Aristotle

Share this post


Link to post
Share on other sites
I couldn''t quite follow your post ... and am not an expect on this at all ... but I do have 2 things to say which may help your mental picture a little.

1. You can fairly well ignore the thoughts about "what if the body cannot rotate, then it just does strait translation" ... this is 100% true, but the ONLY reason a body cannot rotate is if it is either PART of a larger ridgid body, or is impacting another body ... so for you basic minimal simulation of independent reactions of bodies to forces, this will not matter at all ... all of your bodies (masses) are assumed to be able to freely translate and rotate, as if alone in space (right?).

2. Contrary to some people''s belief and experience, it is impossible to cause a free body to rotate by applying a single force on it ... without also causing some amount of translation.

The equations you end up with should probably end up computing the angular and linear (translation) adjustments seperately, with no regaurd for eachother ... because you are speaking of INSTENTANEOUS acceleration here ... a single instance of force transfer ... and of course the laws of conservation of energy says the totals MUST equal the original force total ... but that is a consequence of using correct math to computer each set of numbers, NOT because of specially appied interaction between the two.

Of couse to simulate objects attached to other objects and such ... all sorts of crazy interactions occur ... but that''s far more adanced ..

P.S. What are you planning to do with the acceleration variables? Are you going to act like each force which you apply is acting on the object over a nominal period of time ... and from that determine an average acceleration for purposes of G forces and such?

Share this post


Link to post
Share on other sites
thanks right, i guess i have todo a bit of clarifying

1. yea i agree, having an immovable (linear or angular) mass just doesnt make sense, even if its in a system of other objects, it still has the capability of movement, its just the forces being applied to it by the other objects its connected to prohibit this.

at the moment im trying to keep it as simple as possible, just an object in space with the ability of free motion (linear and angular) ignoring all constraints, i just want to model the reaction of the mass when a force is exerted on it.

2. im not sure myself on this, what if the force is applied in a direction that is perfectly perpendicular to the vector from the center of mass to the application point? as its perpendicular would this cause no translation? of course im going on the assumption i made in my reply earlier that the translation of te mass depends on how much of the force being aplied acts in the direction of the vector from the application point to the center of mass.

quote:

The equations you end up with should probably end up computing the angular and linear (translation) adjustments seperately


yes i think they would too, as, again going on my previous assumption the direction of the force that results in translation is/shoud/would be perpendicular the direction of the force that would cause angular acceleration.

yes i am thinking of instantaneous acceleration, for every frame a force will be applied to a point which will cause an acceleration.

well, what i intend todo with the acceleration at the end of this is simply apply it to the objects velocity. i would like all the forces acting on the object at any one time to be summed up internally by the object and have an overall linear and angular acceleration be produced every frame.

thanks for your input, you have made things much more clear and it appears im kinda on the right track i still need to understand a lot more

"We are what we repeatedly do. Excellence, then, is not an act, but a habit." - Aristotle

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Xai
1. You can fairly well ignore the thoughts about "what if the body cannot rotate, then it just does strait translation" ... this is 100% true, but the ONLY reason a body cannot rotate is if it is either PART of a larger ridgid body, or is impacting another body ... so for you basic minimal simulation of independent reactions of bodies to forces, this will not matter at all ... all of your bodies (masses) are assumed to be able to freely translate and rotate, as if alone in space (right?).



If you were to an object with a finite mass, but with the mass distributed at an infinite distance from the center of mass, then you would have an object that could translate but not rotate.

I only mentioned it because it is easy to do in a simulation.

The angular and liner acceleration are seperate. Xai is explaining it quite well.

Share this post


Link to post
Share on other sites
ok, after searching this forum for related posts i came across this:

http://www.gamedev.net/community/forums/topic.asp?topic_id=51845

which highlights a problem that my current thinking would not resolve :s this forces me to rethink how i apply multiple forces to an object. instead of taking each force, calculating the components of this force into the force in the direction of the vector to the center of mass from the application point and the force perpendicular to that force, i would have to first sum up all the forces as well as their application points, resulting in an overall force at an overall location relative to the center of mass.

so, using the diagram presented in the link above:


p----->f
|
|
|
|
o cm
|
|
|
|
q----->g


where o is the center of mass, p is the application point of force f, and q is the application point of force g. we need to find not only the overall force on the object, but also the overall application point, so we sum the force, and average the application points to get:


p
|
|
|
|
cm o----------->fg
|
|
|
|
q


where o is now the center of mass _and_ the application point, which is found by averaging the application points. the overall force however is just summed resulting in an overall force, gf.

after we have summed all the forces acting an the object and found the overall application point by averaging all the application points of the various forces we then convert this resulting force into components along the vector from the overall application point to the center of mass and the vector thats perpendicular to this vector.

actually thinking about what ive just said i dont think its right, what if in the above diagram the force f is negated so its pointing in the opposite direction?


f<-----p
|
|
|
|
o cm
|
|
|
|
q----->g

in this case, using what i said above, the forces would cancel out and the overall application point would be the center of mass which is clearly wrong.

gah im really really confused now. really need someone to clarify all this for me

"We are what we repeatedly do. Excellence, then, is not an act, but a habit." - Aristotle

Share this post


Link to post
Share on other sites
I''m not going to comment on your last post until I get a chance to read some of my physics book an think a while (I would hate to lead you astray now - and I personally have never even implemented quaternions ...)

The one thing I can add, is some more info as to why I say you cannot rotate and object without causing translation ... the reason is because it is impossible for there to ever be a force which acts on a body with a vector which is 100% perpendicular ... 100% perpendicular to an outer point would be just barely NOT touching the object ... if there is friction between these objects, then the force vector will be slightly less than perpendicular ... although I will say, for your purposes, you can treat 100% perpendicular either way you want (pure rotation, or no force transfer) and it will be fine ... since there is really no way to compute simulations with enough accuracy for it to ever matter ... and the pure rotation idea may allow you to create situations which would otherwise be too complicated ...)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You can rotate if you have two forces, though. Think of two rocket engines at each end of a stick, pointing in opposite directions.

The angular MOMENTUM is conserved, in WORLD SPACE. Meanwhile, the angular inertia is expressed as a constant inertia tensor in OBJECT SPACE. This makes for all kinds of fun!

Contrary to linear movement, where you can calculate velocity or momentum, and they''ll always be parallel / in sync, this is NOT TRUE for rotation. You have to conserve the angular momentum, and you have to integrate to get velocity.

If your object is symmetrical around three axes, your inertia tensor is diagonal, and you could represent it as a simple three-vector, but don''t let that fool you.

A good book is "Classical Mechanics" and a good name for papers is "Baraff".

If your tensor calculus is a bit rusty, you might want to look at the ODE (Open Dynamics Engine) which comes with source for free, and does all of this. It also does a bunch of collision/penetration cases, and constrained joints, for you. Unfortunately, it doesn''t do arbitrary meshes; you''ll have to add that on your own (or drop in some code available on the net).

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by Fusi0n
... i would have to first sum up all the forces as well as their application points, resulting in an overall force at an overall location relative to the center of mass.



p----->f
|
|
o cm
|
|
q--->g


Object is the object, force is the force vector, and offset is the location relative to the CM.

object->force += force;
object->angle_force += magnitude(force) * magnitude(offset) * dot_product(force, offset);

For 2d it is that simple.

And, to make things even better, you can just cancel out the magnitude(force), and magnitude(offset) with the division part of the dot product, so

magnitude(force) * magnitude(offset) * dot_product(force, offset)
=
magnitude(force) * magnitude(offset) * ((force.x*offset.x+force.y*offset.y)/magnitude(force) * magnitude(offset))

so, the whole thing you do for each force is:
object->force += force;
object->angle_force += (force.x*offset.x + force.y*offset.y);

2d is nice and simple, so all you do after accumulating the linear and angular force components is:

object->accel = object->force / object->mass;
object->angle_accel = object->angle_force / object->moment_of_inertia;

Share this post


Link to post
Share on other sites
thanks for the response everyone, but im still really confused :/

earlier i proposed that we can seperate the contact force into its component parts along the vector from the contact point to the center of mass and along the vector perpendicular to that, to seperate the force into its linear and angular parts that result in linear and angular acceleration. this would work fine if there is only ever one force being applied to the object at any one time.

however, when we take into account more than one force acting on the object, the previous solution breaks down and no longer works, especially when we deal with forces that result in some sort of angular acceleration.

this proposition of working with the angular momentum is interesting, althought i dont know enough about it and how it applies right now. i assume angular momentum is roughly the same as linear momentum, p=mv, but where v is now the angular velocity. how would we work this out for more than one force? i think what the real problem here is how we add up all the forces acting on an object at any one time and how to get an overall angular and linear acceleration from them.

going back to the latest post by Anonymous Poster, you say i should just add the overall force to the linear force acting on the object, how can this be correct? if the force is being applied at a contact force thats not in line with the center of mass it would surely create some angular acceleration as well, in which case just adding the force to the linear force acting on the body would result in more resulting energy in the system that was put in in the first place!

as Xai says, you can never ave a force acting on a body that only results in angular acceleration, and thinking about it, Xia is correct. but still, using the ideas i had about one force acting on a body this would still not work, ive clearly srewed up somewhere.

going back to the first diagram in my latest post, if we have two forces that act in the same direction on different sides of an object that result only in angular acceleration, how would we convert the result of these forces into linear acceleration, as they cancel each other out when it comes to angular acceleration, but should result in linear acceleration. how would we find the force resulting from these two forces that does this?

i dont think starting coding at this point would yeild any useful results, the way this whole thing works still needs to be understood, this is clearly a really complicated puzzle that at first looked simpler than what it really is. as always, any feedback is most welcome thanks


"We are what we repeatedly do. Excellence, then, is not an act, but a habit." - Aristotle

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I resign.

Just read all the papers listed on this page:
http://www-2.cs.cmu.edu/afs/cs/user/baraff/www/pbm/pbm.html

Then read all the ones listed here:
http://www.d6.com/users/checker/dynamics.htm

That''s how I learned it.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Actually, read this first. It answers your question about how the force that causes linear and angular acceleration does more work. Since work=force*distance, the force is applied over a larger distance because the point on the object turns.

http://www-2.cs.cmu.edu/afs/cs/user/baraff/www/pbm/rigid1.pdf
on page 28, at "5.5 Force vs. Torque Puzzle"

Share this post


Link to post
Share on other sites
i guess ive just got to go away read those things over and over until i understand every word and equation ;/

thanks for all your help everyone, ill post my findings to this thread when/if i ever figure this out

"We are what we repeatedly do. Excellence, then, is not an act, but a habit." - Aristotle

Share this post


Link to post
Share on other sites
mm ok i think im getting it, slowly what we do is we take the whole force and just apply it to the center of mass.. Baraff says:

"Now suppose that the same force F is applied off-center to the body as shown in figure 11. Since the force acting on the body is the same, the acceleration of the center of mass is the same."

im taking this to mean we just apply the force to the center of mass like a previous anonymous poster told me todo

we then, independantly of what we have just done, find out how much of the force makes the object spin and then apply that.

in effect summing up all the linear forces and applying them to the center of mass, and summing up all the resulting torques and applying that.

it all makes a creppy kind of sense now, but im still stuck on a few things, not the implementation, but a few real world scenarios where i cant quite see how this works....

take a hardback book, and wrap an elastic band around it so it doesnt fall open. hold it on a table so that only the spine is in contact with the table surface. as dipicted below:



/ / / / /
/ /
book > / /
/ /
/ /
/ /
/ /
/ /
/ /
/ /
\ /
\ /
_______\/___________________

^ ^
spine table


now let go of the book. depending on how rough the surface is, the book will either just fall flat, without the spine moving on the table top, or the book will move slightly to the side (to the right in this case) when it hits.

my guess as to whats happening here is that the table is not exerting a force on the center of the book, but at the place where the book comes in contact with the table, at its spine. as the only force really acting on the book is gravity [EDIT: and the normal force from the table top], and Baraff tells us that this force acts on the center of mass, how come the book moves to the side a bit when its front/back cover hits the table?

"We are what we repeatedly do. Excellence, then, is not an act, but a habit." - Aristotle

[edited by - fusi0n on May 4, 2003 8:56:40 PM]

Share this post


Link to post
Share on other sites
this just keeps getting more and more fun ;/ i just finished reading (read: desperately trying to understand a single equation/word) Baraff''s rigid2.pdf paper (http://www-2.cs.cmu.edu/afs/cs/user/baraff/www/pbm/rigid2.pdf). oh my word this is one hell of a subject to start on i understand all the force acting on a body stuff now, thats ok, im actually in the process of writing code that does it. i also understand how to deal with multiple collisions, although i havent written that code yet.

what i am totally bamboozled on is this resting contact stuff! quadratic coding and whatnot - i dont even know what that is :s i dont think i will ever implement such a system, as it looks waaaaaaaaaaay too complicated for my liking. but i was wondering if there is a way around it, a way to approximate resting contact without having to mess about with all that nastiness?

at the moment im thinking for each contact point, if the relative velocity of the objects is zero i could just ''stick'' them together as it were, and as soon as the relative velocity becomes greater than zero treat them as independant objects again. likewise if the relative velocity is less than 0 i could just push the objects back out of each other a bit. any thoughts on this?

going back to what i previousley posted about the book - thats all about frictional contacts isnt it - which, after reading Baraff''s second paper (link above) appears to be just as complex :/ i think i may have to fudge that area too as it really is way over my head, im so dumb :D

i guess its now a case of not understanding or implementing this rbd system, but more a case of fudging the areas i can never hope to code correctly, namely the resting contact and frictional contact areas. does anyone know of how i might go about fudging this, or know of anyone who has done a similar sort of thing and resorted to simpler solutions?

thanks for your support and time everyone who has replied to this thread with your input and links i feel i have learnt something worthwhile

"We are what we repeatedly do. Excellence, then, is not an act, but a habit." - Aristotle

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Multiple resting contacts are the most difficult part of the simulation. The "quadratic coding and whatnot" is not the easiest way to do it.

If you go to:
http://www-2.cs.cmu.edu/~baraff/papers/

You want to read this one:
http://www-2.cs.cmu.edu/~baraff/papers/sig94.pdf

I have read a lot of papers about this subject, and this seems to be the most practical method to handle multiple contacts with friction.

Share this post


Link to post
Share on other sites