2013-11-12 00:10:48 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
// Created by Dan Andersson 2013
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef OYSTER_PHYSICS_3D_H
|
|
|
|
#define OYSTER_PHYSICS_3D_H
|
|
|
|
|
|
|
|
#include "OysterMath.h"
|
|
|
|
|
|
|
|
namespace Oyster { namespace Physics3D
|
|
|
|
{ /// Library of 3D physics related components, alghorithms and formulas
|
|
|
|
namespace Formula
|
|
|
|
{ /// Library of 3D physics related formulas
|
|
|
|
|
2013-12-18 14:16:13 +01:00
|
|
|
/******************************************************************
|
|
|
|
* Returns the linear momentum of a mass in motion.
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
|
|
|
inline ::Oyster::Math::Float4 LinearMomentum( const ::Oyster::Math::Float &mass, const ::Oyster::Math::Float4 &linearVelocity )
|
|
|
|
{
|
|
|
|
return linearVelocity * mass;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* Returns the linear momentum of a mass in motion.
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
|
|
|
inline ::Oyster::Math::Float4 LinearVelocity( const ::Oyster::Math::Float &mass, const ::Oyster::Math::Float4 &linearMomentum )
|
|
|
|
{
|
|
|
|
return linearMomentum / mass;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* Returns the world angular momentum of a mass in rotation.
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
|
|
|
inline ::Oyster::Math::Float4 AngularMomentum( const ::Oyster::Math::Float4 linearMomentum, const ::Oyster::Math::Float4 &worldOffset )
|
|
|
|
{
|
|
|
|
return ::Oyster::Math::Float4( worldOffset.xyz.Cross(linearMomentum.xyz), 0.0f );
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* Returns the world angular momentum of a mass in rotation.
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
|
|
|
inline ::Oyster::Math::Float4 AngularMomentum( const ::Oyster::Math::Float4x4 &worldMomentOfInertia, const ::Oyster::Math::Float4 &angularVelocity )
|
|
|
|
{
|
|
|
|
return worldMomentOfInertia * angularVelocity;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* Returns the world angular velocity of a mass in rotation.
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
|
|
|
inline ::Oyster::Math::Float4 AngularVelocity( const ::Oyster::Math::Float4x4 &worldMomentOfInertiaInversed, const ::Oyster::Math::Float4 &angularMomentum )
|
|
|
|
{
|
|
|
|
return worldMomentOfInertiaInversed * angularMomentum;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* Returns the world tangential momentum at worldPos, of a mass in rotation.
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
|
|
|
inline ::Oyster::Math::Float4 TangentialLinearMomentum( const ::Oyster::Math::Float4 &angularMomentum, const ::Oyster::Math::Float4 &worldOffset )
|
|
|
|
{
|
|
|
|
return ::Oyster::Math::Float4( angularMomentum.xyz.Cross(worldOffset.xyz), 0.0f );
|
|
|
|
}
|
|
|
|
|
2013-11-12 00:10:48 +01:00
|
|
|
/******************************************************************
|
|
|
|
* Returns the linear kinetic energy of a mass in motion.
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
|
|
|
inline ::Oyster::Math::Float LinearKineticEnergy( const ::Oyster::Math::Float &mass, const ::Oyster::Math::Float3 &linearVelocity )
|
2013-11-12 12:33:52 +01:00
|
|
|
{
|
|
|
|
return (0.5f * mass) * linearVelocity.Dot( linearVelocity );
|
|
|
|
}
|
2013-11-12 00:10:48 +01:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* Returns the angular kinetic energy of a mass in rotation.
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
|
|
|
inline ::Oyster::Math::Float AngularKineticEnergy( const ::Oyster::Math::Float &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity )
|
2013-11-12 12:33:52 +01:00
|
|
|
{
|
|
|
|
return (0.5f * momentOfInertia) * angularVelocity.Dot( angularVelocity );
|
|
|
|
}
|
2013-11-12 00:10:48 +01:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* Returns the linear momentum of a mass in motion.
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
|
|
|
inline ::Oyster::Math::Float3 LinearMomentum( const ::Oyster::Math::Float &mass, const ::Oyster::Math::Float3 &linearVelocity )
|
2013-11-12 12:33:52 +01:00
|
|
|
{
|
|
|
|
return mass * linearVelocity;
|
|
|
|
}
|
2013-11-12 00:10:48 +01:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* Returns the linear velocity of a mass with momentum.
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
|
|
|
inline ::Oyster::Math::Float3 LinearVelocity( const ::Oyster::Math::Float &mass, const ::Oyster::Math::Float3 &linearMomentum )
|
2013-11-12 12:33:52 +01:00
|
|
|
{
|
|
|
|
return linearMomentum / mass;
|
|
|
|
}
|
2013-11-12 00:10:48 +01:00
|
|
|
|
|
|
|
/******************************************************************
|
2013-11-20 17:40:12 +01:00
|
|
|
* Returns the world angular momentum of a mass in rotation.
|
2013-11-12 00:10:48 +01:00
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
2013-11-12 12:33:52 +01:00
|
|
|
inline ::Oyster::Math::Float3 AngularMomentum( const ::Oyster::Math::Float4x4 &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity )
|
|
|
|
{
|
|
|
|
return ( momentOfInertia * ::Oyster::Math::Float4(angularVelocity, 0.0f) ).xyz;
|
|
|
|
}
|
2013-11-12 00:10:48 +01:00
|
|
|
|
2013-11-13 14:50:08 +01:00
|
|
|
/******************************************************************
|
2013-11-20 17:40:12 +01:00
|
|
|
* Returns the world angular momentum of a mass in rotation.
|
2013-11-13 14:50:08 +01:00
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
2013-11-20 17:40:12 +01:00
|
|
|
inline ::Oyster::Math::Float3 AngularMomentum( const ::Oyster::Math::Float3 linearMomentum, const ::Oyster::Math::Float3 &worldOffset )
|
2013-11-13 14:50:08 +01:00
|
|
|
{
|
2013-11-21 11:47:20 +01:00
|
|
|
return worldOffset.Cross( linearMomentum );
|
2013-11-13 14:50:08 +01:00
|
|
|
}
|
|
|
|
|
2013-11-12 00:10:48 +01:00
|
|
|
/******************************************************************
|
2013-11-20 17:40:12 +01:00
|
|
|
* Returns the world tangential momentum at worldPos, of a mass in rotation.
|
2013-11-12 00:10:48 +01:00
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
2013-11-20 17:40:12 +01:00
|
|
|
inline ::Oyster::Math::Float3 TangentialLinearMomentum( const ::Oyster::Math::Float3 &angularMomentum, const ::Oyster::Math::Float3 &worldOffset )
|
2013-11-12 12:33:52 +01:00
|
|
|
{
|
2013-11-20 17:40:12 +01:00
|
|
|
return angularMomentum.Cross( worldOffset );
|
2013-11-12 12:33:52 +01:00
|
|
|
}
|
2013-11-12 00:10:48 +01:00
|
|
|
|
|
|
|
/******************************************************************
|
2013-11-20 17:40:12 +01:00
|
|
|
* Returns the world tangential momentum at worldPos, of a mass in rotation.
|
2013-11-12 00:10:48 +01:00
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
2013-11-20 17:40:12 +01:00
|
|
|
inline ::Oyster::Math::Float3 TangentialLinearMomentum( const ::Oyster::Math::Float4x4 &momentOfInertia, const ::Oyster::Math::Float3 &angularVelocity, const ::Oyster::Math::Float3 &worldOffset )
|
2013-11-12 12:33:52 +01:00
|
|
|
{
|
2013-11-20 17:40:12 +01:00
|
|
|
return TangentialLinearMomentum( AngularMomentum(momentOfInertia, angularVelocity), worldOffset );
|
2013-11-12 12:33:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2013-11-20 17:40:12 +01:00
|
|
|
* Returns the world impulse force at worldPos, of a mass in angular acceleration.
|
2013-11-12 12:33:52 +01:00
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
2013-11-20 17:40:12 +01:00
|
|
|
inline ::Oyster::Math::Float3 TangentialImpulseForce( const ::Oyster::Math::Float3 &impulseTorque, const ::Oyster::Math::Float3 &worldOffset )
|
2013-11-12 12:33:52 +01:00
|
|
|
{
|
2013-11-20 17:40:12 +01:00
|
|
|
return impulseTorque.Cross( worldOffset );
|
2013-11-12 12:33:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
*
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
|
|
|
inline ::Oyster::Math::Float3 AngularImpulseAcceleration( const ::Oyster::Math::Float4x4 &momentOfInertiaInversed, const ::Oyster::Math::Float3 &impulseTorque )
|
|
|
|
{
|
|
|
|
return ( momentOfInertiaInversed * ::Oyster::Math::Float4( impulseTorque, 0.0f ) ).xyz;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
*
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
2013-11-20 17:40:12 +01:00
|
|
|
inline ::Oyster::Math::Float3 AngularImpulseAcceleration( const ::Oyster::Math::Float3 &linearImpulseAcceleration, const ::Oyster::Math::Float3 &worldOffset )
|
2013-11-12 12:33:52 +01:00
|
|
|
{
|
2013-11-21 11:39:11 +01:00
|
|
|
return worldOffset.Cross( linearImpulseAcceleration );
|
2013-11-12 12:33:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2013-11-20 11:58:27 +01:00
|
|
|
* Returns the world impulse acceleration at ( worldOffset = worldPos - body's center of gravity ), of a mass in angular acceleration.
|
2013-11-12 12:33:52 +01:00
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
2013-11-20 11:58:27 +01:00
|
|
|
inline ::Oyster::Math::Float3 TangentialImpulseAcceleration( const ::Oyster::Math::Float4x4 &worldMomentOfInertiaInversed, const ::Oyster::Math::Float3 &worldImpulseTorque, const ::Oyster::Math::Float3 &worldOffset )
|
2013-11-12 12:33:52 +01:00
|
|
|
{
|
2013-11-20 11:58:27 +01:00
|
|
|
return AngularImpulseAcceleration( worldMomentOfInertiaInversed, worldImpulseTorque ).Cross( worldOffset );
|
2013-11-12 12:33:52 +01:00
|
|
|
}
|
2013-11-12 00:10:48 +01:00
|
|
|
|
|
|
|
/******************************************************************
|
2013-11-20 17:40:12 +01:00
|
|
|
* Returns the world angular velocity of a mass in rotation.
|
2013-11-12 00:10:48 +01:00
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
2013-11-12 12:33:52 +01:00
|
|
|
inline ::Oyster::Math::Float3 AngularVelocity( const ::Oyster::Math::Float4x4 &momentOfInertiaInversed, const ::Oyster::Math::Float3 &angularMomentum )
|
|
|
|
{
|
|
|
|
return ( momentOfInertiaInversed * ::Oyster::Math::Float4( angularMomentum, 0.0f ) ).xyz;
|
|
|
|
}
|
2013-11-12 00:10:48 +01:00
|
|
|
|
2013-11-21 11:39:11 +01:00
|
|
|
/******************************************************************
|
|
|
|
* Returns the world angular velocity of a mass in rotation.
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
|
|
|
inline ::Oyster::Math::Float3 AngularVelocity( const ::Oyster::Math::Float3 &linearVelocity, const ::Oyster::Math::Float3 &worldOffset )
|
|
|
|
{
|
|
|
|
return worldOffset.Cross( linearVelocity );
|
|
|
|
}
|
|
|
|
|
2013-11-12 00:10:48 +01:00
|
|
|
/******************************************************************
|
2013-11-20 17:40:12 +01:00
|
|
|
* Returns the world tangential velocity at worldPos, of a mass in rotation.
|
2013-11-12 00:10:48 +01:00
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
2013-11-20 17:40:12 +01:00
|
|
|
inline ::Oyster::Math::Float3 TangentialLinearVelocity( const ::Oyster::Math::Float3 &angularVelocity, const ::Oyster::Math::Float3 &worldOffset )
|
2013-11-12 12:33:52 +01:00
|
|
|
{
|
2013-11-21 11:47:20 +01:00
|
|
|
return angularVelocity.Cross( worldOffset );
|
2013-11-12 12:33:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
2013-11-20 17:40:12 +01:00
|
|
|
* Returns the world tangential velocity at worldPos, of a mass in rotation.
|
2013-11-12 12:33:52 +01:00
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
2013-11-20 17:40:12 +01:00
|
|
|
inline ::Oyster::Math::Float3 TangentialLinearVelocity( const ::Oyster::Math::Float4x4 &momentOfInertiaInversed, const ::Oyster::Math::Float3 &angularMomentum, const ::Oyster::Math::Float3 &worldOffset )
|
2013-11-12 12:33:52 +01:00
|
|
|
{
|
2013-11-21 11:47:20 +01:00
|
|
|
return TangentialLinearVelocity( AngularVelocity(momentOfInertiaInversed, angularMomentum), worldOffset );
|
2013-11-12 12:33:52 +01:00
|
|
|
}
|
2013-11-12 00:10:48 +01:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
*
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
|
|
|
inline ::Oyster::Math::Float3 LinearImpulseAcceleration( ::Oyster::Math::Float mass, const ::Oyster::Math::Float3 &impulseForce )
|
2013-11-12 12:33:52 +01:00
|
|
|
{
|
|
|
|
return impulseForce / mass;
|
|
|
|
}
|
2013-11-12 00:10:48 +01:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
*
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
|
|
|
inline ::Oyster::Math::Float3 ImpulseForce( ::Oyster::Math::Float mass, const ::Oyster::Math::Float3 &linearImpulseAcceleration )
|
2013-11-12 12:33:52 +01:00
|
|
|
{
|
|
|
|
return linearImpulseAcceleration * mass;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
*
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
2013-11-20 17:40:12 +01:00
|
|
|
inline ::Oyster::Math::Float3 ImpulseTorque( const ::Oyster::Math::Float3 & impulseForce, const ::Oyster::Math::Float3 &worldOffset )
|
2013-11-12 12:33:52 +01:00
|
|
|
{
|
2013-11-21 11:47:20 +01:00
|
|
|
return worldOffset.Cross( impulseForce );
|
2013-11-12 12:33:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* T = I*a
|
|
|
|
* @todo TODO: improve doc
|
|
|
|
******************************************************************/
|
|
|
|
inline ::Oyster::Math::Float3 ImpulseTorque( const ::Oyster::Math::Float4x4 & momentOfInertia, const ::Oyster::Math::Float3 &angularImpulseAcceleration )
|
|
|
|
{
|
|
|
|
return ( momentOfInertia * ::Oyster::Math::Float4(angularImpulseAcceleration, 0.0f) ).xyz;
|
|
|
|
}
|
2013-11-12 00:10:48 +01:00
|
|
|
|
|
|
|
namespace MomentOfInertia
|
|
|
|
{ /// Library of Formulas to calculate moment of inerta for simple shapes
|
2013-11-12 12:33:52 +01:00
|
|
|
/** @todo TODO: add MomentOfInertia tensor formulas */
|
2013-11-21 11:47:34 +01:00
|
|
|
inline ::Oyster::Math::Float CalculateSphere( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius )
|
|
|
|
{
|
|
|
|
return (2.0f/5.0f)*mass*radius*radius;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ::Oyster::Math::Float4x4 Sphere( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius )
|
|
|
|
{
|
|
|
|
::Oyster::Math::Float4x4 inertia = ::Oyster::Math::Float4x4::identity;
|
|
|
|
inertia.m[0][0] = ::Oyster::Physics3D::Formula::MomentOfInertia::CalculateSphere( mass , radius );
|
|
|
|
inertia.m[1][1] = inertia.m[0][0];
|
|
|
|
inertia.m[2][2] = inertia.m[0][0];
|
|
|
|
|
|
|
|
return inertia;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ::Oyster::Math::Float CalculateHollowSphere( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius )
|
|
|
|
{
|
|
|
|
return (2.0f/3.0f)*mass*radius*radius;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ::Oyster::Math::Float4x4 HollowSphere( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius )
|
|
|
|
{
|
|
|
|
::Oyster::Math::Float4x4 inertia = ::Oyster::Math::Float4x4::identity;
|
|
|
|
inertia.m[0][0] = ::Oyster::Physics3D::Formula::MomentOfInertia::CalculateHollowSphere( mass, radius );
|
|
|
|
inertia.m[1][1] = inertia.m[0][0];
|
|
|
|
inertia.m[2][2] = inertia.m[0][0];
|
|
|
|
|
|
|
|
return inertia;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ::Oyster::Math::Float CalculateCuboidX( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float depth )
|
|
|
|
{
|
|
|
|
return (1.0f/12.0f)*mass*(height*height + depth*depth);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ::Oyster::Math::Float CalculateCuboidY( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float width, const ::Oyster::Math::Float depth )
|
|
|
|
{
|
|
|
|
return (1.0f/12.0f)*mass*(width*width + depth*depth);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ::Oyster::Math::Float CalculateCuboidZ( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float width, const ::Oyster::Math::Float height )
|
|
|
|
{
|
|
|
|
return (1.0f/12.0f)*mass*(height*height + width*width);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ::Oyster::Math::Float4x4 Cuboid( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float width, const ::Oyster::Math::Float depth )
|
|
|
|
{
|
|
|
|
::Oyster::Math::Float4x4 inertia = ::Oyster::Math::Float4x4::identity;
|
|
|
|
inertia.m[0][0] = ::Oyster::Physics3D::Formula::MomentOfInertia::CalculateCuboidX( mass , height, depth );
|
|
|
|
inertia.m[1][1] = ::Oyster::Physics3D::Formula::MomentOfInertia::CalculateCuboidY( mass , width, depth );
|
|
|
|
inertia.m[2][2] = ::Oyster::Physics3D::Formula::MomentOfInertia::CalculateCuboidZ( mass , height, width );
|
|
|
|
|
|
|
|
return inertia;
|
|
|
|
}
|
2013-11-22 08:58:00 +01:00
|
|
|
|
|
|
|
inline ::Oyster::Math::Float CalculateRodCenter( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float length )
|
|
|
|
{
|
|
|
|
return (1.0f/12.0f)*mass*(length*length);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ::Oyster::Math::Float4x4 RodCenter( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float length )
|
|
|
|
{
|
|
|
|
::Oyster::Math::Float4x4 inertia = ::Oyster::Math::Float4x4::identity;
|
|
|
|
inertia.m[0][0] = ::Oyster::Physics3D::Formula::MomentOfInertia::CalculateRodCenter( mass , length );
|
|
|
|
inertia.m[1][1] = inertia.m[0][0];
|
|
|
|
inertia.m[2][2] = inertia.m[0][0];
|
|
|
|
|
|
|
|
return inertia;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ::Oyster::Math::Float CalculateCylinderXY( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float radius )
|
|
|
|
{
|
|
|
|
return (1.0f/12.0f)*mass*(3.0f*radius*radius + height*height);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ::Oyster::Math::Float CalculateCylinderZ( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float radius )
|
|
|
|
{
|
|
|
|
return 0.5f*mass*(radius*radius);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ::Oyster::Math::Float4x4 Cylinder( const ::Oyster::Math::Float mass, const ::Oyster::Math::Float height, const ::Oyster::Math::Float radius )
|
|
|
|
{
|
|
|
|
::Oyster::Math::Float4x4 inertia = ::Oyster::Math::Float4x4::identity;
|
|
|
|
inertia.m[0][0] = ::Oyster::Physics3D::Formula::MomentOfInertia::CalculateCylinderXY( mass , height, radius );
|
|
|
|
inertia.m[1][1] = inertia.m[0][0];
|
|
|
|
inertia.m[2][2] = ::Oyster::Physics3D::Formula::MomentOfInertia::CalculateCylinderZ( mass , radius );
|
|
|
|
|
|
|
|
return inertia;
|
|
|
|
}
|
2013-11-21 11:47:34 +01:00
|
|
|
|
2013-11-12 00:10:48 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} }
|
|
|
|
|
|
|
|
#include "Particle.h"
|
|
|
|
#include "RigidBody.h"
|
|
|
|
#include "Spring.h"
|
|
|
|
|
|
|
|
#endif
|