## 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

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

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

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

### Re: NewtonConvexCollisionCalculateInertialMatrix in 2.0 beta 14

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;   real centre = { 0, 0, 0 };   NewtonConvexCollisionCalculateInertialMatrix( priv->collision, inertia, centre );   NewtonBodySetMassMatrix( priv->body, 1.0, inertia, inertia, inertia );   NewtonBodySetUserData( priv->body, this );   NewtonBodySetLinearDamping( priv->body, 0.0 );   wVector zero = wVector(0,0,0,0);   NewtonBodySetAngularDamping( priv->body, &zero );   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

Not sure, but I do NewtonBodySetMassMatrix(body, mass, i * mass, i * mass, i * 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

this is the correct way
NewtonBodySetMassMatrix( priv->body, mass, mass * inertia, mass * inertia, mass * inertia );
Julio Jerez
Moderator Posts: 11154
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles