Jump to content
  • Advertisement
Sign in to follow this  
_WeirdCat_

Mass distribution

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

If you intended to correct an error in the post then please contact us.

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

 

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.

 

 

Share this post


Link to post
Share on other sites
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

Edited by Randy Gaul

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!