Mass distribution

Started by
4 comments, last by Randy Gaul 8 years, 2 months ago

I need somehow to find a mass of each point on the surface of my ships hull (that souds silly)

because i need to apply rotation (torque) to each individual part of the triangle (that forms a hull) (I = I0 + md^2)

like shown on this pic

mpsd.jpg

since i always was slicing body into smaller fragments like (cubes) i was lets say i divide one cube into smaller ones (all smaller cubes have the same dimension) so i could eaisly estimate the mass of the cube and apply that torque, now i am completely out of ideas how should i do that.

Advertisement

Well torque is r x F, where r is the red vector in your picture, and F is whatever force you're trying to apply. This cross product will generate a torque that can be used to modify angular velocity. I don't think you need to use approximation or point-masses since Stan Melax open sourced the code for calculating the inertia tensor of a model given the model's triangles.

You can treat your boat as a rigid body with a center of mass, inertia tensor, and mass. If you'd like to apply a force at a point on the boat you can do:

//--------------------------------------------------------------------------------------------------

void RigidBody::ApplyForceAtWorldPoint( v3 F, v3 point )
{
m_force += F;
m_torque += Cross( point - m_center, F );
}

To integrate the linear force and torque:

linearVel += dt * mass * linearForce

angularVel + dt * inverseInertiaTensor * torque

This means you need to calculate your boats inverse inertia tensor. Code for this is up on Stan Melax's website, he has a function that takes triangles and returns the inertia tensor. The tensor is best calculated in model space of the boat, and each can be transformed to world space by: inverseInertiaTensor = R * inertiaTensor * R^T, where R is the boat's orientation matrix.

Links:

Melax Volint

My implementation from Melax's page and Box2D

Randy, don't you mean:


//--------------------------------------------------------------------------------------------------
void RigidBody::ApplyForceAtWorldPoint( v3 F, v3 point )
{
    m_force += F;
    m_torque += Cross( point - m_center, F );
}

?

Randy, don't you mean:


//--------------------------------------------------------------------------------------------------
void RigidBody::ApplyForceAtWorldPoint( v3 F, v3 point )
{
    m_force += F;
    m_torque += Cross( point - m_center, F );
}

?

Yes, that bug was who knows how old :)

Yeah i saw Ixx, Iyy, Izz that was that inverseInertiaTensor and was applied to rotation part, but is there a good simple explanation why its calculated the way it is?

Stan had a good GDC lecture about a lot of things, including how he derived that inertia tensor calculation: http://www.gdcvault.com/play/1017654/Math-for-Game-Programmers-Interaction

This topic is closed to new replies.

Advertisement