Program Listing for File SpatialInertia.h

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&body_to_cm,
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::string_viewtypeString()const;

doublemass()const;

constVec3&bodyToCm()const;

constVec3&mp()const;

constMat33&inertia()const;

constMat33&cmInertia()const;

std::stringdumpString(std::string_viewprefix="",
unsignedintprecision=10,
boolexponential=false)const;

voiddump(std::string_viewprefix="",
unsignedintprecision=10,
boolexponential=false)const;

SpatialVectoroperator*(constSpatialVector&vec)const;

constMat66&matrix()const;

constSpatialInertiaparallelAxis(constHomTran&T)const;

protected:
void_setInertia(
doublemass,constVec3&body_to_cm,constMat33&inertia,boolat_cm,boolvalidate);

void_validateInertia(constMat33&inertia)const;//NOLINT(readability-identifier-naming)

Mat33_parallelAxisCmInertiaOffset(constVec3&offset)const;

private:
double_mass=uninitializedNaN;
Vec3_body_to_cm,_mp;
Mat33_inertia,_cm_inertia;

mutablebool_cached_spi_matrix_flag=false;
mutableMat66_cached_spi_matrix;
};

}//namespaceKarana::Math