Math Problem...adding a force at a certain point

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Math Problem...adding a force at a certain point

Postby pHySiQuE » Sun Dec 01, 2013 1:39 pm

This is my code to add a force at a specific point at a body. I think it's wrong. Can you help?:
Code: Select all
    void Entity::AddPointForce(const Vec3& force, const Vec3& position)
    {
      Vec3 r = position - this->GetPosition();
      Vec3 torque = r.Cross(force);
      this->AddForce(force);
      this->AddTorque(torque);
    }


It doesn't seem right that the full force would be added to an object if it is only hit on an edge.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Math Problem...adding a force at a certain point

Postby pHySiQuE » Sun Dec 01, 2013 2:05 pm

I think I answered my own question...the force should be multiplied by the dot product of itself and the collided surface before being added.
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Math Problem...adding a force at a certain point

Postby Julio Jerez » Sun Dec 01, 2013 3:53 pm

This is correct yes.
Code: Select all
void Entity::AddPointForce(const Vec3& force, const Vec3& position)
    {
      Vec3 r = position - this->GetPosition();
      Vec3 torque = r.Cross(force);
      this->AddForce(force);
      this->AddTorque(torque);
    }

the first code was right, the second post make no sense and is just wrong.

the only thing on the first post is that I am guessing that this->GetPosition();
is giving you the matrix location, you nee the center of mass location in global space.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Math Problem...adding a force at a certain point

Postby JoeJ » Sun Dec 01, 2013 3:58 pm

pHySiQuE wrote:I think I answered my own question...the force should be multiplied by the dot product of itself and the collided surface before being added.


Exactly what i have thought about it, but this is wrong, and your code snippet is right.
Google for it... thousands have the same question.

When discussing with Julio he said that the rotational motion is 'cancelled out' by the opposite motion on the other side of the com, so it requires no energy.
... at least that's how i understood it. I was happy with it for a while, but there are still some doubpts about it... it is so hard to believe.

I still think that when i hit a pencil resting in deep space at its end point with a force perpendicular to its axis, it should only rotate and not move.
I'd like to see that experiemnt in reality :)

EDIT:
I tried it with pencil on glass: Rotation but almost no movement. :|
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Math Problem...adding a force at a certain point

Postby pHySiQuE » Sun Dec 01, 2013 4:55 pm

If a bullet hits the side of an object with a glancing blow like this, wouldn't less force be applied to the object?:
Image2.jpg
Image2.jpg (8.33 KiB) Viewed 5417 times
pHySiQuE
 
Posts: 608
Joined: Fri Sep 02, 2011 9:54 pm

Re: Math Problem...adding a force at a certain point

Postby JoeJ » Sun Dec 01, 2013 5:18 pm

See at the bottom: http://www.myphysicslab.com/collision.html
This is impulse calculation.
Implementation (collision dynamic / static object only) below from Chris Heckers physics tutorial code.
Don't know where it is in newton and if it has some tools for this suff...

All this calculates a instant velocity change (Impulse).
If you want to apply a force (should be more stable), you need to change some things. *)
The dot product you said is part of it (but it applies before calculating the angular responce).

*) Edit:
Ending up with your...

vec3 relVel = bullet.velocity - objectVelAtCollisionPoint;
force = relVel.Dot(collisionNormal) * someConstantContainingBulletMass * coeffOfRestitution;
Vec3 r = position - this->GetPosition();
Vec3 torque = r.Cross(force);
this->AddForce(force);
this->AddTorque(torque);

... looks totally right for me (force integration handles mass/inertia stuff for you).
If you're happy with it, ignore that complex stuff :)

Code: Select all
void simulation_world::ResolveCollisions( int ConfigurationIndex )
{
    rigid_body &Body = aBodies[CollidingBodyIndex];
    rigid_body::configuration &Configuration =
        Body.aConfigurations[ConfigurationIndex];
   
    vector_3 Position =
        Configuration.aBoundingVertices[CollidingCornerIndex];
   
    vector_3 R = Position - Configuration.CMPosition;

    vector_3 Velocity = Configuration.CMVelocity +
        CrossProduct(Configuration.AngularVelocity,R);
   
    real ImpulseNumerator = -(r(1) + Body.CoefficientOfRestitution) *
        DotProduct(Velocity,CollisionNormal);

    real ImpulseDenominator = Body.OneOverMass +
        DotProduct(CrossProduct(Configuration.InverseWorldInertiaTensor *
                                CrossProduct(R,CollisionNormal),R),
                   CollisionNormal);
   
    vector_3 Impulse = (ImpulseNumerator/ImpulseDenominator) * CollisionNormal;
   
    // apply impulse to primary quantities
    Configuration.CMVelocity += Body.OneOverMass * Impulse;
    Configuration.AngularMomentum += CrossProduct(R,Impulse);
   
    // compute affected auxiliary quantities
    Configuration.AngularVelocity = Configuration.InverseWorldInertiaTensor *
        Configuration.AngularMomentum;
}


Edit2: added some stuff i have had forgotten at first.
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Math Problem...adding a force at a certain point

Postby Julio Jerez » Sun Dec 01, 2013 9:41 pm

if you hit a pencil in the vacuum, on any point the each particle on the body will acquire an change of momentum
F * dt = M * dv
and a change of torque
F * R * dt = I * dw

every single point on that mass will acquire an change the exact same on linear velocity.
if you do not want the cent of mass to no move you need to apply a pair of force on the same direction by different ordinations so that the net force is zero but the net toque is not.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Math Problem...adding a force at a certain point

Postby Sweenie » Tue Dec 03, 2013 10:25 am

I tried it with pencil on glass: Rotation but almost no movement.


I thought alot about this as well and the thing is, you can't recreate a perfect impulse, complete vacuum and zero friction in real life.
When you hit the tip of the pen horizontally with your finger you are pushing the pen and after a few moments(milliseconds or even microseconds) the pen will rotate and as soon as the pen starts to rotate your finger will start to slide off it thus applying alot lesser force horizontally then a few microseconds ago. And at some point some of that force is applied more vertically then horizontally.
But if you hit the pen with the same amount of force right in the middle, the pen won't slide of your finger and instead get the full horizontal force for a longer time, thus recieving a much higher linear velocity.
Just as Physique mentions with the glancing blow, the formula doesn't account for declined force and friction due to the object applying the force sliding off the object.

Check this clip out, good stuff on the topic.
http://www.youtube.com/watch?v=EOy1NV21pMY&sns=em
Fast forward to 15:00 mins into the clip. :)
Sweenie
 
Posts: 503
Joined: Mon Jan 24, 2005 7:59 am
Location: Sweden

Re: Math Problem...adding a force at a certain point

Postby Julio Jerez » Tue Dec 03, 2013 12:01 pm

I love those videos.

I like the part at 46, where the little gem stops and start spinning in he worn direction.

if you do that with a physic engine that first thon anybody would think is that the PhysX engine is bogus.
and they you see that that kind of stuff really do happens. I know there must be an expansion but, wow is very estrange that is does that.

One of the thing that you get with physics simulation is that hymen thinks we are familiar with many physic subjects, by in reality we are familiar with very small examples.
a simulation allows you to mix parameter in a way that is is no comment in real ordinary.

the simplex explain to me is the free fall of large objects, they look slow motion in a simulation by in fact they false at the correct rate.
the other example f the extreme inertia ratios. and I believe that the beat on that lecture does that spin trick because the extreme inertia ratio.

I will see if I can recreate that behavior in Newton, I need to readable the not uniform scale that I commented out about a month ago, but I am sure Newton can reproduce that.
Maybe I can try with a convex hull, but I believe a scale sphere will be the only shape that could do that.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Math Problem...adding a force at a certain point

Postby JernejL » Thu Jan 16, 2014 4:30 am

I'm not very good about relationships between force and torque, but what is the correct way to accumulate several addforce+addtorque sequences into one addforce+addtorque? i'd like to have these calls data pre-prepared and just add them once in forcetorque without using a queue or something like that.
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1587
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Math Problem...adding a force at a certain point

Postby AntonSynytsia » Thu Jan 16, 2014 5:45 am

pHySiQuE wrote:If a bullet hits the side of an object with a glancing blow like this, wouldn't less force be applied to the object?:
Image2.jpg


You should see this video:
http://www.youtube.com/watch?v=N8HrMZB6_dU&feature=c4-overview&list=UUHnyfMqiRRG1u-2MsSQLbXA
I don't know if less force will be applied to an object, but it still reaches the same height compared to the one shot at center.
AntonSynytsia
 
Posts: 193
Joined: Sat Dec 28, 2013 6:36 pm

Re: Math Problem...adding a force at a certain point

Postby Julio Jerez » Thu Jan 16, 2014 6:02 am

I think the Is sping block should reach a lower elevation, I am 100% sure of that.

something is not right on that experiment, Maybe the problem is that the very high different in energy transfer is making the bullet pass a different amount on energy
but I am 100% sure that making everythin equal the spinning block should reach lower altitude.

They will both move, but if the same amount of energy is transferred, some of that energy will be converts to angular energy.

The linear momentum is conserver independently than the angular momentum. for the center hit what block gain the bullet loses. the bullet should be bounce back without spinning
in the off center hit, the bullet should be bouncing back with a really high spin, but that still does no explain why the reach the same high.
I am curies to see the explanation.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Math Problem...adding a force at a certain point

Postby AntonSynytsia » Thu Jan 16, 2014 6:15 am

I agree with you Julio.

But, the bullet penetrated inside the block (became part of it), which made it distribute the the momentum, no matter where it was in the block.
http://www.youtube.com/watch?v=BLYoyLcdGPc
Skip to 5:30
AntonSynytsia
 
Posts: 193
Joined: Sat Dec 28, 2013 6:36 pm

Re: Math Problem...adding a force at a certain point

Postby AntonSynytsia » Thu Jan 16, 2014 6:19 am

The bullet didn't go as far into the spinning block, which made it pass more energy to the block shot in the side than the block shot into center.
AntonSynytsia
 
Posts: 193
Joined: Sat Dec 28, 2013 6:36 pm

Re: Math Problem...adding a force at a certain point

Postby Julio Jerez » Thu Jan 16, 2014 11:14 am

This is what said linear and angular momentum are independent variables, for the lineal what the bullet wins the bullet must lose, with the part where he said that there is lot of momentum lost.
these is because the conservation of momentum only apply for Eleatic collision but the is a plastic collision, the bullet deform that world a lot, an that take a lot of energy

part of there energy can in fact be converted on angular energy, why in turn can be converts to angular momentum and tha is the explanation.
The energy Tranter in eh collision is the part the is negligible.

you can estimate tha form the masses of each body and the velocity.

the mass if the word is of the order of say 10 time the mass of the bullet.
10 * Mb = Mw

before collision the velocity of the bullet is or the order is about a thousand time the velocity of the bullet plus the mass
so form conservation of energy let us say is only 100 time faster

100 Vw = Vb

Mb * Vb^2 = (Mb + Mw) * Vw^2 + LostEnery
Mb * (100 Vw) ^2 = (Mb + Mb/10) * Vw^2 + LostEnery

from The identity you can see that the right size is huge compare to (Mb + Mb/10) * V^2

10000 * Mb * Vw ^2 >> (Mb + Mb/10) * V^2

so the lost of energy is huge.

under that condition there is no problem whatsoever in some of the energy be converted to the small angular momentum energy.
The problem is that people think of ideal conservation of momentum, but the example of far form ideal,
if he is a block of not deformable material, where the lose are small, they the would will reach a lower elevation.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron