so I am trying to determine exactly how much torque to apply to a 3d model to make it rotate at a particular rate. I apply force from the location of each engine on the craft so if one breaks the craft should start to spiral out of control. Unity provides the inertia tensor which as far as I can figure out is the distribution of mass simplified to a vector? I am assuming Unity's own physics system relies on the same vector.. If I had a target rotation speed and for the sake of simplicity wanted to accelerate to it over one frame I'd like to be able to do something like:
AddForce(targetAngularVelocity * rigidbody.mass * rigidbody.inertiaTensor.magnitude);
assuming the inertiaTensor has a magnitude of the average distribution of mass is that how it works? hopefully you get the point because im making some assumptions here I can't really seem to find a clear answer - that I understand anyway :)
A better explanation: I can get the angular velocity of a rigidbody from unity, but how do I convert that into torque using the inertia tensor. For example if you have two rotating spheres both with the same mass and angular velocity but one is larger, the larger one will take more torque to stop it because of its mass distribution. How do I utilise the inertia tensor to determine the torque required?
Been messing around with the tensor, created a 3D object -> Cube in Unity, added a rigidbody, then added a second cube as a child of the first. By moving the child cube the inertia tensor changes.. I set Unity to draw a vector of the inertia tensor.. it did appear at first to remain constantly perpendicular to the mass distribution.. but it seems to only be directed along a positive diagonal along the plane closest to that perpendicular of the mass distribution..
I really need someone with knowledge on the topic to shed some light on this. What does Unity use to determine how a mass will react to a force offset from the centre of mass? I just need to know how to predict how Unity will react by applying a throttle to a single engine on, for example the wing of the plane.
The tensor appears strangely simple? can only span along 3 directions, each a positive only diagonal along a plane perpendicular to the distribution of mass.. an estimate almost? with a degree of error of 90 degrees?
Please tell me I'm missing something
2 upvotes, must be a record for me, so I've put some more time in haha, I hope this helps someone.
so theres another Vector3 I should have looked at long ago.. Unity also supplies Rigidbody.inertiaTensorRotation which is the euler angles for the rotation of the inertia tensor. After drawing a vector along the inertia tensor rotated by the cubes local rotation and also the inertia tensor rotation it works. The line still flickers at 90 degree rotations but it doesn't matter as it is representing the distribution of mass out from the axis that is running through the transforms position and it's centre of mass. In other words rotating the inertia tensor around the imaginary vector connecting the 2 cubes won't change it's meaning, hence why I draw the 4, it stopped the change.
The picture here shows the inertia tensor, in white. That was confusing me before as it is in global co-ordinates. The way it changes to match (to a degree) the rotation of the cubes distribution of mass made me think it was local co-ords. The green lines indicate the inertia tensor. I have drawn it 4 times, each rotated 90 degrees around the axis going through the transforms position and its centre of mass. The inertia tensor randomly changes between one of these 4, but the way it changes doesn't change how it represents the inertia moment.. just look at the pic ;)
So the inertia tensor after rotating is like a plane around the axis that mass is distributed along. Because the mass is only the 2 cubes, the distribution is by a majority along the axis going through the transforms location and its centre of mass. the inertia tensor is also slightly tipping towards one of the cubes if you look closely. That is representing the slight distribution out perpendicular to the vector I keep mentioning running through the transforms position and its centre of mass (or draw a line between the 2 cubes).
Oh yeah, so how do I use this magical vector to determine the torque required to rotate it to a specific angular momentum?
Update, again.. Sorry to keep coming back to this, it is driving me insane. All I need to know is how the inertia tensor affects the resulting angular momentum after a torque is applied.