NewtonConvexCollisionCalculateInertialMatrix in 2.0 beta 14

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

NewtonConvexCollisionCalculateInertialMatrix in 2.0 beta 14

Postby Gianluca » Fri Sep 05, 2008 4:53 am

Hello everybody,
probably I use the NewtonConvexCollisionCalculateInertialMatrix in the wrong way... this is the code:
Code: Select all
   real inertia[3];
   real centre[3] = { 0, 0, 0 };
   NewtonConvexCollisionCalculateInertialMatrix( priv->collision, inertia, centre );
   NewtonBodySetMassMatrix( priv->body, mass, inertia[0], inertia[1], inertia[2] );


mass is calculated manually... because objects are small it vary within [0.1, 1.0].
Also the dimensions of the objects are quite small.
I tried also to scale dimensions and masses by 10 ... but the problem persists.

The problem is that with inertia calculate above the joint behaves very strange (often the simulation is near to explode)
but if I set the inertia to 1.0 for all values
Code: Select all
   NewtonBodySetMassMatrix( priv->body, mass, 1.0, 1.0, 1.0 );


It behaves correctly.

Suggestions ???

Thanks,
Gianluca
Gianluca
 
Posts: 53
Joined: Fri Nov 11, 2005 4:37 am
Location: Rome - Italy

Re: NewtonConvexCollisionCalculateInertialMatrix in 2.0 beta 14

Postby Julio Jerez » Fri Sep 05, 2008 9:19 am

can you post a sample of one objects?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonConvexCollisionCalculateInertialMatrix in 2.0 beta 14

Postby Gianluca » Mon Sep 08, 2008 6:55 am

Yes, of course.
This is the code when I create an object:
Code: Select all
   priv->collision = NewtonCreateSphere( worldpriv->world, radiusv, radiusv, radiusv, 0 );
   priv->body = NewtonCreateBody( worldpriv->world, priv->collision );
   NewtonBodySetAutoSleep( priv->body, 0 );
   real inertia[3];
   real centre[3] = { 0, 0, 0 };
   NewtonConvexCollisionCalculateInertialMatrix( priv->collision, inertia, centre );
   NewtonBodySetMassMatrix( priv->body, 1.0, inertia[0], inertia[1], inertia[2] );
   NewtonBodySetUserData( priv->body, this );
   NewtonBodySetLinearDamping( priv->body, 0.0 );
   wVector zero = wVector(0,0,0,0);
   NewtonBodySetAngularDamping( priv->body, &zero[0] );
   NewtonBodySetAutoSleep( priv->body, 0 );
   NewtonReleaseCollision( worldpriv->world, priv->collision );
   // Sets the signal-wrappers callback
   NewtonBodySetTransformCallback( priv->body, (PhyObjectPrivate::setTransformHandler) );
   NewtonBodySetForceAndTorqueCallback( priv->body, (PhyObjectPrivate::applyForceAndTorqueHandler) );


The only row that changes when I create different object is the first.

Thank you,
Gianluca.
Gianluca
 
Posts: 53
Joined: Fri Nov 11, 2005 4:37 am
Location: Rome - Italy

Re: NewtonConvexCollisionCalculateInertialMatrix in 2.0 beta 14

Postby agi_shi » Wed Dec 24, 2008 4:47 pm

Not sure, but I do NewtonBodySetMassMatrix(body, mass, i[0] * mass, i[1] * mass, i[2] * mass) (that is, multiply the inertia by the pass) - does that change anything?
agi_shi
 
Posts: 263
Joined: Fri Aug 17, 2007 6:54 pm

Re: NewtonConvexCollisionCalculateInertialMatrix in 2.0 beta 14

Postby Julio Jerez » Wed Dec 24, 2008 4:55 pm

this is the correct way
NewtonBodySetMassMatrix( priv->body, mass, mass * inertia[0], mass * inertia[1], mass * inertia[2] );
Julio Jerez
Moderator
Moderator
 
Posts: 12249
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 9 guests