Program Listing for File SpatialInertia.h#
↰ Return to documentation for file (include/Karana/Math/SpatialInertia.h)
/*
*Copyright(c)2024-2025KaranaDynamicsPtyLtd.Allrightsreserved.
*
*NOTICETOUSER:
*
*Thissourcecodeand/ordocumentation(the"LicensedMaterials")is
*theconfidentialandproprietaryinformationofKaranaDynamicsInc.
*UseoftheseLicensedMaterialsisgovernedbythetermsandconditions
*ofaseparatesoftwarelicenseagreementbetweenKaranaDynamicsandthe
*Licensee("LicenseAgreement").Unlessexpresslypermittedunderthat
*agreement,anyreproduction,modification,distribution,ordisclosure
*oftheLicensedMaterials,inwholeorinpart,toanythirdparty
*withoutthepriorwrittenconsentofKaranaDynamicsisstrictlyprohibited.
*
*THELICENSEDMATERIALSAREPROVIDED"ASIS"WITHOUTWARRANTYOFANYKIND.
*KARANADYNAMICSDISCLAIMSALLWARRANTIES,EXPRESSORIMPLIED,INCLUDING
*BUTNOTLIMITEDTOWARRANTIESOFMERCHANTABILITY,NON-INFRINGEMENT,AND
*FITNESSFORAPARTICULARPURPOSE.
*
*INNOEVENTSHALLKARANADYNAMICSBELIABLEFORANYDAMAGESWHATSOEVER,
*INCLUDINGBUTNOTLIMITEDTOLOSSOFPROFITS,DATA,ORUSE,EVENIF
*ADVISEDOFTHEPOSSIBILITYOFSUCHDAMAGES,WHETHERINCONTRACT,TORT,
*OROTHERWISEARISINGOUTOFORINCONNECTIONWITHTHELICENSEDMATERIALS.
*
*U.S.GovernmentEndUsers:TheLicensedMaterialsarea"commercialitem"
*asdefinedat48C.F.R.2.101,andareprovidedtotheU.S.Government
*onlyasacommercialenditemunderthetermsofthislicense.
*
*AnyuseoftheLicensedMaterialsinindividualorcommercialsoftwaremust
*include,intheuserdocumentationandinternalsourcecodecomments,
*thisNotice,Disclaimer,andU.S.GovernmentUseProvision.
*/
#pragmaonce
#include"Karana/Math/Defs.h"
#include"Karana/Math/HomTran.h"
#include"Karana/Math/SpatialVector.h"
#include<cfloat>
namespaceKarana::Math{
usingnamespaceEigen;
classSpatialInertia{
//Constructors
public:
SpatialInertia();
voiduninitialize();
boolisInitialized()const;
SpatialInertia(doublemass,constVec3&b2cm,constMat33&inertia,boolvalidate=true);
//Copyconstructor,moveconstructor,andassignmentoperators
public:
SpatialInertia(constSpatialInertia&other);
voidsetZero();
SpatialInertia&operator=(constSpatialInertia&other);
SpatialInertia(SpatialInertia&&other)noexcept;
SpatialInertia&operator=(SpatialInertia&&other)noexcept;
SpatialInertiaoperator+(constSpatialInertia&other)const;
SpatialInertiaoperator-(constSpatialInertia&other)const;
SpatialInertia&operator+=(constSpatialInertia&other);
SpatialInertia&operator-=(constSpatialInertia&other);
public:
booloperator==(constSpatialInertia&other)const;
boolisApprox(constSpatialInertia&other,doubleprec=MATH_EPSILON);
std::stringtypeString()const;
doublemass()const{return_mass;}
constVec3&b2cm()const{return_b2cm;}
constVec3&mp()const{return_mp;}
constMat33&inertia()const{return_inertia;}
constMat33&cmInertia()const{return_cm_inertia;}
std::stringdumpString(conststd::string&prefix="",
unsignedintprecision=10,
boolexponential=false)const;
voiddump(conststd::string&prefix="",
unsignedintprecision=10,
boolexponential=false)const;
SpatialVectoroperator*(constSpatialVector&vec)const{
Vec3w=_inertia*vec.getw()+_mp.cross(vec.getv());
Vec3v=vec.getw().cross(_mp)+_mass*vec.getv();
returnSpatialVector(w,v);
}
constMat66&matrix()const;
constSpatialInertiaparallelAxis(constHomTran&T)const;
void
_setInertia(doublemass,constVec3&b2cm,constMat33&inertia,boolat_cm,boolvalidate);
void_validateInertia(constMat33&inertia)const;
Mat33_parallelAxisCmInertiaOffset(constVec3&offset)const;
private:
double_mass=-FLT_MAX;
Vec3_b2cm,_mp;
Mat33_inertia,_cm_inertia;
mutablebool_cached_spi_matrix_flag=false;
mutableMat66_cached_spi_matrix;
};
}//namespaceKarana::Math