Follow this link to skip to the main content

claraty::Mass_Properties Class Reference

#include <me_body.h>

Collaboration diagram for claraty::Mass_Properties:

Collaboration graph
[legend]
List of all members.

Mass_Properties constructors/destructors

static const int NUM_INERTIA_TENSOR_ROWS = 3
static const int NUM_INERTIA_TENSOR_COLUMNS = 3
static const int NUM_INERTIA_VALUES = 9
 Mass_Properties ()
 Mass_Properties (const Mass_Properties &mass_properties)
 ~Mass_Properties ()

Public Member Functions

Mass_Properties model update
void get (double &density, double &volume, double &mass)
void set (double density, double volume, double mass)
void set_center_of_mass (Transform &center_of_mass)
Transformget_center_of_mass ()
void get_inertia (Matrix< double > &moments)
void set_inertia (Matrix< double > &moments)
void update_mass ()

Private Attributes

double _rho
double _volume
double _mass
Transform _center_of_mass
Inertia _inertia

Friends

std::ostream & operator<< (std::ostream &os, Mass_Properties &mass_properties)

Detailed Description

Mass_Properties class The Mass_Properties class contains parameters for the material density, volume, mass and inertia of a ME_Body. It uses the Inertia struct to contain the inertia properties. It also has a Transform object to specify the location (position and orientatin) of its center of mass.

Definition at line 67 of file me_body.h.


Constructor & Destructor Documentation

claraty::Mass_Properties::Mass_Properties (  ) 

Default Constructor for a Mass_Properties object.

Definition at line 43 of file me_body.cc.

References _inertia, _mass, _rho, _volume, claraty::Inertia::moments, NUM_INERTIA_TENSOR_COLUMNS, NUM_INERTIA_TENSOR_ROWS, and claraty::N_2D_Array< T >::resize().

00044 {
00045   _rho = 0.0;
00046   _volume = 0.0;
00047   _mass = 0.0;
00048 
00049   _inertia.moments.resize(NUM_INERTIA_TENSOR_ROWS,
00050                           NUM_INERTIA_TENSOR_COLUMNS);
00051   for (int i=0; i<3; ++i)
00052     for (int j=0; j<3; ++j)
00053       _inertia.moments(i,j) = 0.0;
00054 }

Here is the call graph for this function:

claraty::Mass_Properties::Mass_Properties ( const Mass_Properties mass_properties  ) 

Copy constructor

Definition at line 63 of file me_body.cc.

References _center_of_mass, _inertia, _mass, _rho, _volume, and claraty::Inertia::moments.

00064 {
00065   _rho = mass_properties._rho;
00066   _volume = mass_properties._volume;
00067   _mass = mass_properties._mass;
00068 
00069   // Use copy constructor of Transform obj
00070   _center_of_mass = mass_properties._center_of_mass;    
00071 
00072   _inertia.moments = mass_properties._inertia.moments;
00073 
00074 }

claraty::Mass_Properties::~Mass_Properties (  ) 

Destructor

Definition at line 82 of file me_body.cc.

00083 {
00084 }


Member Function Documentation

void claraty::Mass_Properties::get ( double &  density,
double &  volume,
double &  mass 
)

Get attribute values.

Parameters:
[out] density 
[out] volume 
[out] mass 

Definition at line 120 of file me_body.cc.

References _mass, _rho, and _volume.

Referenced by claraty::operator<<().

00121 {
00122   density = _rho;
00123   volume = _volume;
00124   mass = _mass;
00125 }

void claraty::Mass_Properties::set ( double  density,
double  volume,
double  mass 
)

Set attribute values.

Parameters:
[in] density 
[in] volume 
[in] mass 

Definition at line 137 of file me_body.cc.

References _mass, _rho, and _volume.

Referenced by claraty::Mass_Properties_IO::extract_from_parse_tree().

00138 {
00139   _rho = density;
00140   _volume = volume;
00141   _mass = mass;
00142 }

void claraty::Mass_Properties::set_center_of_mass ( Transform center_of_mass  ) 

Add Center of mass transform to Mass Properties.

Parameters:
[in] center_of_mass 

Definition at line 106 of file me_body.cc.

References _center_of_mass.

00107 {
00108   _center_of_mass = center_of_mass;
00109 }

Transform & claraty::Mass_Properties::get_center_of_mass (  ) 

Get Center of mass transform to Mass Properties.

Returns:
Center of mass transform.

Definition at line 94 of file me_body.cc.

References _center_of_mass.

Referenced by claraty::Mass_Properties_IO::extract_from_parse_tree(), claraty::operator<<(), and claraty::ME_Body::rotate_center_of_mass().

00095 {
00096   return _center_of_mass;
00097 }

void claraty::Mass_Properties::get_inertia ( Matrix< double > &  moments  ) 

Get inertia attribute values.

Parameters:
[out] moments 

Definition at line 152 of file me_body.cc.

References _inertia, and claraty::Inertia::moments.

Referenced by claraty::operator<<(), and claraty::ME_Body::rotate_inertia_tensor().

00153 {
00154   moments = _inertia.moments;
00155 }

void claraty::Mass_Properties::set_inertia ( Matrix< double > &  moments  ) 

Set inertia attribute values.

Parameters:
[in] moments 

Definition at line 164 of file me_body.cc.

References _inertia, and claraty::Inertia::moments.

Referenced by claraty::Mass_Properties_IO::_set_inertia_attributes(), and claraty::ME_Body::rotate_inertia_tensor().

00165 {
00166   _inertia.moments = moments;
00167 }

void claraty::Mass_Properties::update_mass (  )  [inline]

Definition at line 90 of file me_body.h.

References _mass, _rho, and _volume.

00090 {_mass = _rho * _volume;}


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
Mass_Properties mass_properties 
) [friend]

Output to ostream

Parameters:
[out] os ostream to put output on.
[in] mass_properties Display_Graphics_IO object to be output.
Returns:
ostream with output on it.

Definition at line 179 of file me_body.cc.

00181 {
00182   // Children of this node will have this indentation at the
00183   // start of each line
00184   std::string spacing = "";
00185   std::string child_spacing = "";
00186   std::string grandchild_spacing = "";
00187   spacing.append(XML_Out::get_indentation_space(), ' ');
00188   child_spacing.append(XML_Out::get_indentation_space()
00189                        + XML_Out::get_tab_space(), ' ');
00190   grandchild_spacing.append(XML_Out::get_indentation_space()
00191                        + 2 * XML_Out::get_tab_space(), ' ');
00192 
00193   double density, volume, mass;
00194   mass_properties.get(density, volume, mass);
00195   // Write the Mass Properties data to the string
00196   os << spacing;
00197   os << "<Mass_Properties ";
00198 
00199   os << "rho = \"" << density << "\" ";
00200 
00201   os << "volume = \"" << volume << "\" ";
00202 
00203   os << "mass = \"" << mass << "\" >\n";
00204 
00205   // Write the Center of Mass data to the string
00206   os << child_spacing;
00207   os << "<CM>\n";
00208   os << grandchild_spacing;
00209   os << "<Transform>\n";
00210 
00211   XML_Out::increment_indentation_level(3);
00212   os << XML_Out::enable << mass_properties.get_center_of_mass() 
00213      << XML_Out::disable;
00214   XML_Out::decrement_indentation_level(3);
00215 
00216   os << grandchild_spacing;
00217   os << "</Transform>\n";
00218   os << child_spacing;
00219   os << "</CM>\n";
00220 
00221   // Write the Inertia data to the string
00222   Matrix<double> moments(Mass_Properties::NUM_INERTIA_TENSOR_ROWS,
00223                          Mass_Properties::NUM_INERTIA_TENSOR_COLUMNS);
00224   mass_properties.get_inertia(moments);
00225   os << child_spacing;
00226   os << "<Inertia ";
00227 
00228   os << "xx = \"" << moments(0,0) << "\" ";
00229   os << "xy = \"" << moments(0,1) << "\" ";
00230   os << "xz = \"" << moments(0,2) << "\" ";
00231 
00232   os << "yx = \"" << moments(1,0) << "\" ";
00233   os << "yy = \"" << moments(1,1) << "\" ";
00234   os << "yz = \"" << moments(1,2) << "\" ";
00235 
00236   os << "zx = \"" << moments(2,0) << "\" ";
00237   os << "zy = \"" << moments(2,1) << "\" ";
00238   os << "zz = \"" << moments(2,2) << "\" />\n";
00239 
00240   os << spacing;
00241   os << "</Mass_Properties> \n";
00242 
00243   return os;
00244 }


Member Data Documentation

Material density

Definition at line 94 of file me_body.h.

Referenced by get(), Mass_Properties(), set(), and update_mass().

Body volume

Definition at line 95 of file me_body.h.

Referenced by get(), Mass_Properties(), set(), and update_mass().

Body mass

Definition at line 96 of file me_body.h.

Referenced by get(), Mass_Properties(), set(), and update_mass().

Body center of mass

Definition at line 97 of file me_body.h.

Referenced by get_center_of_mass(), Mass_Properties(), and set_center_of_mass().

Body inertia

Definition at line 98 of file me_body.h.

Referenced by get_inertia(), Mass_Properties(), and set_inertia().


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