Problems with Impulseadditivity

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Problems with Impulseadditivity

Postby Shredd0r » Tue Oct 11, 2011 10:18 am

Hi I have some problems with adding (lots) of impulses to a body.

The impulse's locations are gained by rastering a plane of a body (it should simulate the influence of an explosion). The problem now is that impulses added on the sides seems to have less effect than in the middle. The impulse distribution is uniform.
The problem appears in that way, so that a body with more height gets more accelerated than a flat one (same mass).
I believe this is caused by the angle between impulse position and the center of mass.

Thanks to whom have read this
Attachments
Unbenannt.png
Unbenannt.png (7.03 KiB) Viewed 3222 times
Shredd0r
 
Posts: 10
Joined: Fri Apr 08, 2011 9:53 am

Re: Problems with Impulseadditivity

Postby Julio Jerez » Tue Oct 11, 2011 10:44 am

what you describe is correct, impulse are not just a linear physical effect, there are also rotational
basically an impulse apply an change of momentum to a body center mass
the change of momentum is a function of the Body mass, Inertia, and proportional to the distance from the point of acting to the center of mass.
The change of momentum is fix, but its distribution depend of the above values, so the farther away the point of action is, the more of the momentum goes to change angular velocity and less to change linear velocity.

what function are you using to apply impulse? this void dgBody::AddImpulse (const dgVector& pointDeltaVeloc, const dgVector& pointPosit)
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Problems with Impulseadditivity

Postby mic » Tue Oct 11, 2011 11:30 am

Thanks for the reply,

ShreddOr and I are using
NEWTON_API void NewtonBodyAddImpulse (const NewtonBody* body, const dFloat* pointDeltaVeloc, const dFloat* pointPosit);

I understand that in the case of adding a single impulse (or a set of impulses non-symmetric around the center of mass) the effect has a transversal and rotational part. But if you add the vertical impulses symmetric around the center of mass down to a cube, the sum of angular momenta is zero and all energy is used for transversal movement. In my eyes the resulting vertical velocity should not depend on the impulse distribution as long as you do not produce an angular momentum of the body. Which point am I missing?
mic
 
Posts: 2
Joined: Tue Oct 11, 2011 11:05 am

Re: Problems with Impulseadditivity

Postby Julio Jerez » Tue Oct 11, 2011 11:43 am

yes you are right if each pair of impulse is simetric then the net angular velocity gain should be zero.

The problem is that if you are using that function that I listed. It will not be zero because that function does not simple apply an impule to a body,
it applyes an impulse to a point and guarantee that the velocity of that point will increase by the amount passed in the argumnet.

That function was writen in the early days of newton and it was influenced by people wanting to push bodies funtion tha disregard teh oteh body mass
a general impulse will not do it, so I made and spcial impulse that add a delat veloccity at a point.
very few people uses that function so I will change it to a General impulse at a point tonight. tha should solve you problem.

Note:
I will simple add another generic impulse funtion to the engine tonight, that should solve the problem and not affect anyone using that function.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Problems with Impulseadditivity

Postby JoeJ » Tue Oct 11, 2011 11:56 am

I smell the answer to a question that gives me headakes for a long time :)
You are talking about a situation like this?...

"
AddGlobalForce (Force, Point)
{
R = Point - BodyMatrix.Position;
Torque = CrossProduct (R, Force);
NewtonAddForce (Force)
NewtonAddTorque (Torque)
}

I saw this code first time in baraffs paper about collission resolving.
Now i see it everywhere. But out of context i miss something on that.
If some energy causes rotation, the force causing linear movement must be reduced - this is not handled in this nice function - why?
"

and further...

"
If i snip the pencil at it's tip, it will rotate but there's nearly none translational motion.
This means to me that if torque is generated, force to apply on com gets smaller.
How to calculate this? I could figure out myself, but there's another question:
If we would do this reduction, and use that on other example: Snip pencil on both tip and end at the same time,
then the torques would sum up to zero, but the forces would also become nearly zero, which is wrong.
"
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Problems with Impulseadditivity

Postby mic » Tue Oct 11, 2011 12:13 pm

Yes, your nice example with the pencil shows exactly our problem.

Julio, thanks a lot for your efforts, we will be online again on thursday.
mic
 
Posts: 2
Joined: Tue Oct 11, 2011 11:05 am

Re: Problems with Impulseadditivity

Postby Shredd0r » Thu Oct 13, 2011 10:39 am

maybe a function that takes an array of impulses with corresponding points that calculates the resulting body's behaviour would do it, but I'm not that confident about how to solve that physics stuff the best way.

anyway thx for the attention :)
Shredd0r
 
Posts: 10
Joined: Fri Apr 08, 2011 9:53 am

Re: Problems with Impulseadditivity

Postby Julio Jerez » Thu Oct 13, 2011 11:22 am

yes that can be possible.
the simplest way if to have the code and add the impulse one at a time, that will no be mathematica correct, and you really nee to implemnet a complementaryy sistem,
hwever in almost 99.9 % of the case it will lead to the desired result.

I have not added the function yet no time afte coming form home but I will try tonight.
I will add that funtion to add teh array of impulse, because it can have some intenal optimization by reusing some sub expresions in the calculation.
But I not write it as a complementatry solver, that takes too long.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Problems with Impulseadditivity

Postby Julio Jerez » Fri Oct 14, 2011 8:12 am

Ok I added that new function to th engine

Code: Select all
void NewtonBodyApplyImpulseArray (const NewtonBody* const body, int impuleCount, int strideInByte, const dFloat* const impulseArray, const dFloat* const pointArray);


the implementation look like this

Code: Select all
void dgBody::ApplyImpulseArray (dgInt32 count, dgInt32 strideInBytes, const dgFloat32* const impulseArray, const dgFloat32* const pointArray)
{
   dgInt32 stride = strideInBytes / sizeof (dgFloat32);

   dgMatrix inertia (CalculateInertiaMatrix());

   dgVector impulse (m_veloc.Scale (m_mass.m_w));
   dgVector angularImpulse (inertia.RotateVector (m_omega));

   dgVector com (m_globalCentreOfMass);
   for (dgInt32 i = 0; i < count; i ++) {
      dgInt32 index = i * stride;
      dgVector r (pointArray[index], pointArray[index + 1], pointArray[index + 2], dgFloat32 (0.0f));
      dgVector L (impulseArray[index], impulseArray[index + 1], impulseArray[index + 2], dgFloat32 (0.0f));
      dgVector Q ((r - com) * L);

      impulse += L;
      angularImpulse += Q;
   }

   dgMatrix invInertia (CalculateInvInertiaMatrix());
   m_veloc = impulse.Scale(m_invMass.m_w);
   m_omega = invInertia.RotateVector(angularImpulse);

   m_sleeping = false;
   m_equilibrium = false;
   Unfreeze ();
}



note that now this is a lkegitimat impulse function, it will take the mass and inertia into account.
heaviest body will get less velocity for the same impulse.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Problems with Impulseadditivity

Postby JoeJ » Fri Oct 14, 2011 4:46 pm

But that does not handle the case like snipping the pencil on both ends simultaneously...?
Now i remember i had a simular situation on collision resolving of two capsules.
My simulater drifted in cases of 2 contact points, so i figured out a formula to merge them to a single contact, which worked well.

So in this case i'd try something like:

vec pos(0,0,0)
vec imp(0,0,0)
float sum = 0

for all impulses do
pos += point[n] * impulse[n].length
imp += impulse[n]
sum += impulse[n].length

merged.point = pos / sum
merged.impulse = imp

Does that make any sense?
User avatar
JoeJ
 
Posts: 1489
Joined: Tue Dec 21, 2010 6:18 pm

Re: Problems with Impulseadditivity

Postby Julio Jerez » Fri Oct 14, 2011 6:05 pm

JoeJ wrote:But that does not handle the case like snipping the pencil on both ends simultaneously...?

Yes it does, what is does not do is to apply a precise impulse to achieve a desired result.
But if you had the impulse it will apply it properly to the body.
Applying impulses is not much different than applying forces, in fact an impulse is a finite force applied for an infinitesimal amount of time
therefore the same equation used to apply forces and torque can also be used to apply impulse and anglular impulses.
In the case of the pencil say you know the impulse on each point and distance at witch to apply the impulse

Say Pi is the inpulse and Ri – c is the distance form each point to the center, From the secund law of mation you have

Sum Fi = m * dv / dt
Sum Ri x Fi = I * dw / dt

From ther integration Fi and Ti indevidually for a small amunt of time, you can asume the Fi is a spike of constant high,
therefore the integration on the left size is the sum of a const value equal to the high of each spike mutiplied by the length of time the impusle is applied.
on the right size mass and inertia are also constant because of the asumtion that the impulse is appled in an infinitesimal amount of time, therefore the body does not
has time to rotate or move. so the equation becomes.

Sum (Fi * dt) = m * v2 – m * v1
Sum ((ri x Fi) * dt) = I * w2 – I * w1

Here impulse Pi = Fi * dt

Sum (Pi) + m * v1 = m * v2
Sum ((ri x Pi) * dt) + m * w0 = I * w2

Now the to get the new velocity and angular velocity

You calculate and acumulate the values from an the left size in a loop, and then
You multiply by the inverse mass and inverse inertia

Inv(m) * ((Sum (Pi) + m * v1) = v2
Inv (Sum (ri x Pi) + m * w0) = w2

Like I said what the function doe no do is to calculate the exact Pi to achieve a desire result, for toy nee a complementary solver of linear system of equations.
if you have Pi. then it is just a applycation.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Problems with Impulseadditivity

Postby Shredd0r » Mon Oct 17, 2011 10:21 am

I have no idea what you are talking about but in a first test the new command works well :)

Great best thanks to you Julio!!!!!
Shredd0r
 
Posts: 10
Joined: Fri Apr 08, 2011 9:53 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron