MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
CenterOfMass Class Reference

#include <inertia.h>

Inheritance diagram for CenterOfMass:
Collaboration diagram for CenterOfMass:

Public Member Functions

 CenterOfMass (std::set< const ElemGravityOwner * > &elements)
 
virtual ~CenterOfMass (void)
 

Protected Member Functions

virtual void Collect_int (void)
 
virtual std::ostream & Output_int (std::ostream &out) const
 

Protected Attributes

std::set< const
ElemGravityOwner * > 
elements
 
doublereal dMass
 
Vec3 S
 
Mat3x3 J
 
Vec3 X_cm
 
Vec3 V_cm
 
Vec3 Omega_cm
 
Mat3x3 J_cm
 

Detailed Description

Definition at line 43 of file inertia.h.

Constructor & Destructor Documentation

CenterOfMass::CenterOfMass ( std::set< const ElemGravityOwner * > &  elements)

Definition at line 102 of file inertia.cc.

References NO_OP.

102  :
104 {
105  NO_OP;
106 }
std::set< const ElemGravityOwner * > elements
Definition: inertia.h:45
#define NO_OP
Definition: myassert.h:74
CenterOfMass::~CenterOfMass ( void  )
virtual

Definition at line 108 of file inertia.cc.

References NO_OP.

109 {
110  NO_OP;
111 }
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

void CenterOfMass::Collect_int ( void  )
protectedvirtual

Reimplemented in Inertia.

Definition at line 59 of file inertia.cc.

References ASSERT, Vec3::Cross(), dMass, elements, Mat3x3::IsSymmetric(), J, J_cm, Mat3x3::LDLSolve(), MatCrossCross, Omega_cm, S, Mat3x3::Symm(), V_cm, X_cm, Zero3, and Zero3x3.

Referenced by Inertia::Collect_int().

60 {
61  dMass = 0.;
62  S = Zero3;
63  J = Zero3x3;
64 
65  Vec3 B(Zero3), G(Zero3);
66 
67  for (std::set<const ElemGravityOwner *>::const_iterator i = elements.begin();
68  i != elements.end(); ++i)
69  {
70  dMass += (*i)->dGetM();
71  S += (*i)->GetS();
72  J += (*i)->GetJ();
73 
74  B += (*i)->GetB();
75  G += (*i)->GetG();
76  }
77 
78  J_cm = J;
79  if (dMass < std::numeric_limits<doublereal>::epsilon()) {
80  X_cm = Zero3;
81  V_cm = Zero3;
82  Omega_cm = Zero3;
83  J_cm = J_cm.Symm();
84 
85  } else {
86  X_cm = S/dMass;
87  V_cm = B/dMass;
88 
89  /*
90  * FIXME: should also rotate it in the principal
91  * reference frame, and log the angles
92  */
94  J_cm = J_cm.Symm();
95 
96  ASSERT(J_cm.IsSymmetric()); // NOTE: should be a run time test
97  Omega_cm = J_cm.LDLSolve(G - X_cm.Cross(B));
98  }
99 }
const Vec3 Zero3(0., 0., 0.)
Vec3 Cross(const Vec3 &v) const
Definition: matvec3.h:218
Definition: matvec3.h:98
Vec3 V_cm
Definition: inertia.h:53
std::set< const ElemGravityOwner * > elements
Definition: inertia.h:45
Mat3x3 J_cm
Definition: inertia.h:55
doublereal dMass
Definition: inertia.h:47
const Mat3x3 Zero3x3(0., 0., 0., 0., 0., 0., 0., 0., 0.)
Vec3 Omega_cm
Definition: inertia.h:54
#define ASSERT(expression)
Definition: colamd.c:977
Vec3 X_cm
Definition: inertia.h:52
Vec3 LDLSolve(const Vec3 &v) const
Definition: matvec3.cc:199
bool IsSymmetric(void) const
Definition: matvec3.h:1260
const MatCrossCross_Manip MatCrossCross
Definition: matvec3.cc:640
Mat3x3 Symm(void) const
Definition: matvec3.h:840
Mat3x3 J
Definition: inertia.h:49
Vec3 S
Definition: inertia.h:48

Here is the call graph for this function:

std::ostream & CenterOfMass::Output_int ( std::ostream &  out) const
protectedvirtual

Reimplemented in Inertia.

Definition at line 47 of file inertia.cc.

References dMass, J, J_cm, Omega_cm, V_cm, and X_cm.

Referenced by Inertia::Output_int().

48 {
49  return out
50  << " mass: " << dMass << std::endl
51  << " J: " << J << std::endl
52  << " Xcg: " << X_cm << std::endl
53  << " Jcg: " << J_cm << std::endl
54  << " Vcg: " << V_cm << std::endl
55  << " Wcg: " << Omega_cm << std::endl;
56 }
Vec3 V_cm
Definition: inertia.h:53
Mat3x3 J_cm
Definition: inertia.h:55
doublereal dMass
Definition: inertia.h:47
Vec3 Omega_cm
Definition: inertia.h:54
Vec3 X_cm
Definition: inertia.h:52
Mat3x3 J
Definition: inertia.h:49

Member Data Documentation

doublereal CenterOfMass::dMass
mutableprotected
std::set<const ElemGravityOwner *> CenterOfMass::elements
protected

Definition at line 45 of file inertia.h.

Referenced by Collect_int().

Mat3x3 CenterOfMass::J
mutableprotected

Definition at line 49 of file inertia.h.

Referenced by Collect_int(), Inertia::Collect_int(), Inertia::GetJ_int(), and Output_int().

Mat3x3 CenterOfMass::J_cm
protected

Definition at line 55 of file inertia.h.

Referenced by Collect_int(), Inertia::Collect_int(), Output_int(), and Inertia::Output_int().

Vec3 CenterOfMass::Omega_cm
protected

Definition at line 54 of file inertia.h.

Referenced by Collect_int(), Inertia::dGetPrivData(), Inertia::Output(), and Output_int().

Vec3 CenterOfMass::S
mutableprotected

Definition at line 48 of file inertia.h.

Referenced by Collect_int(), and Inertia::GetS_int().

Vec3 CenterOfMass::V_cm
protected

Definition at line 53 of file inertia.h.

Referenced by Collect_int(), Inertia::dGetPrivData(), Inertia::Output(), and Output_int().

Vec3 CenterOfMass::X_cm
protected

The documentation for this class was generated from the following files: