# Mass distribution

This topic is 1074 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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

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.

##### Share on other sites

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.

Melax Volint

My implementation from Melax's page and Box2D

Edited by Randy Gaul

##### Share on other sites

Randy, don't you mean:

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


?

##### Share on other sites

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 :)

##### Share on other sites

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?

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 14
• 46
• 22
• 27
• ### Forum Statistics

• Total Topics
634046
• Total Posts
3015221
×