Compound Mass Matrix Seems wrong

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Compound Mass Matrix Seems wrong

Postby MeltingPlastic » Tue Sep 04, 2018 4:32 pm

In the following video - I am seeing some wierd behalvior with a compound I formed. check out the video at 1:20 into the video:
https://youtu.be/M4vl7i0oVRY

I am calculating the mass matrix after I form the whole collision - and the center of mass seems right - anything I could be missing? The mass for the whole is calculated based on the the density and vol of each cone - and that seems to be calculating correctly.

Heres another video to:
https://youtu.be/Xp0z0gA7lEs
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: Compound Mass Matrix Seems wrong

Postby Julio Jerez » Tue Sep 04, 2018 4:54 pm

what is wrong?
you are making a body with a skew inertia.
bodies with skew inertia don't behave intuitivally.
The engine make the assumption, that most objects will have at least one axis of simetry, and that the skew inertia are small compared to the principal axis inertia.
that object breaks that assumption, if you want a more realistic behavior you can make a skew dynamic body which uses the full inertia matrix.
this is more expensive to simulate hence the assumption.


are those single compound?
are you setting the mass using the setmass matrix, passing the collision, or are you setting passing the mass and the ixx, iyy and izz.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compound Mass Matrix Seems wrong

Postby MeltingPlastic » Tue Sep 04, 2018 5:52 pm

The object spins on one end of itself almost perpetually.

It is one single compound yes. And each individual collision shape is only non uniformly scaled and not skewed. I am passing in the mass and the collision shape itself to calculate the matrix.

I double check what I'm doing later when I get home.

I am willing to go the more expensive route to get the behavior right if that's what's needed.

Edit: I think I see now what I am getting into. Did you by chance finish the convenience function for calculating the total ineritia for compounds in this thread?: http://newtondynamics.com/forum/viewtopic.php?f=9&t=8878&p=58059&hilit=inertia+matrix#p58059

When I look at NewtonBodySetFullMassMatrix() it seems it only uses 3 values Ixx, Iyy and Izz from the matrix in the end.

I think it will be super cool to get a full inertia matrix working for whatever compounds you can come up with.
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: Compound Mass Matrix Seems wrong

Postby Julio Jerez » Tue Sep 04, 2018 7:09 pm

the spinning on one corner is a typical wrong behavior that show conservator of angular velocity not angle momentum, the function to use a general inertia is this,
NewtonCreateAsymetricDynamicBody

but I have to tell you unless, you are familiar with what to expect you will see behavior that if you no not see before you will said they are wrong.
look at this video


it seems wrong, until you find out this is real natural behavior:


similarly you will see these


and I have to put side by side real example or else they will look wrong.

I can't tell if by the look of a behavior is right or wrong, I can only go by comparing
angular momentum before and after a time step and check that it is with in acceptable accurate values.
It can never be exact because the numerical integration can never be exact, it can only be with it some acceptable error bound.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compound Mass Matrix Seems wrong

Postby MeltingPlastic » Tue Sep 04, 2018 7:13 pm

Sounds Good, yes I was wondering if it was actually a result of the physics myself at first.

But like you say - if I am not using the full Inertia matrix I cannot know for sure right?

For the rattleback - is there any mass offset that is calculated into the inertia matrix?

I was watching this video and they seem to rattle back better with a mass offset.
https://www.youtube.com/watch?v=11NHjiEYnI0

Still learning about this stuff..
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm

Re: Compound Mass Matrix Seems wrong

Postby Julio Jerez » Tue Sep 04, 2018 7:36 pm

I showed the Rattle back because it has a very, very narrow set of parameters where it works.

It took me hours of trials and error find the spot where the behavior happens.
you can check the demo gyro effects.
I do not know of anyone who actually knows the physics explanation of why it happens
not even some of the people who not only know classical mechanic, they see physics in the ways
I can only dream off do not really know why this happens.


I am quite content with this particular results because it tells me that the integrator, the Collision an the contact generators produce results that sufficiently agree with the natural world in known cases.
so it is likely that with the unknown cases the behavior can be plausible.

That's not to say that I know with certainty they are correct, there are many degenerated cases that can cause any of the systems to produce non sensical results.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compound Mass Matrix Seems wrong

Postby JoeJ » Wed Sep 05, 2018 11:52 am

I have some questions here, i'll start with assumptions, please correct me if i'm wrong...

Looking at the rattleback demo i concluded you use asymmetric inertia to have a different frame to define inertia than the frame to define the ellipsoid collision shape. So asymmetric inertia allows to translate the COM and to rotate the inertia from the collision.
So, as an alternative we could also use a highly tesselated mesh to represent the collision and rotate / translate the vertices instead. Then we would get the same effect without the need for asymmetric inertia, correct?
(Of course tesselated mesh will not give a smooth contact point like analyitical ellipsoid and may be slower, but i just ask to be sure my understanding is right.)

The second question is more important: What frame do you use to represent inertia for compounds? Du you calculate the frame that can represent inertia the most accurate, or do you use the given parent frame (which might be a bad choice in some cases)?
In the latter case i would calculate the ideal frame myself and place / rotate the bodies accordingly before making the compound.
(Never tested this out, but it always confuses me...)
User avatar
JoeJ
 
Posts: 1453
Joined: Tue Dec 21, 2010 6:18 pm

Re: Compound Mass Matrix Seems wrong

Postby MeltingPlastic » Wed Sep 05, 2018 3:26 pm

Ok so when forming a compound I replaced:
Code: Select all
NewtonBodySetMassProperties(newtonBody_, mass_, resolvedCollision);


with:

Code: Select all
NewtonConvexCollisionCalculateInertialMatrix(resolvedCollision, &inertia[0], &com[0]);
NewtonBodySetMassMatrix(newtonBody_, mass_, inertia[0], inertia[1], inertia[2]);
NewtonBodySetCentreOfMass(newtonBody_, &com[0]);


And the behavior seems more natural to my eyes - no more oscillating around the end of a compound. It also rotates a little faster and looks better.

I do have one question:
Given an arbitrary mass distribution: Is it true that if a moment of inertia frame is centered on the center of mass it will never be a skewed matrix?


Also in the urho implementation I am giving CollisionShapes a mass density property. So It is possible that one sub shape could be the same size as another but have different masses. It looks like I need a way to Add up inertia's manually similar to what JoeJ is doing. (Hi JoeJ!)
MeltingPlastic
 
Posts: 237
Joined: Fri Feb 07, 2014 11:30 pm


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 4 guests

cron