include/vamos/geometry/Inertia_Tensor.h

Go to the documentation of this file.
00001 //      Vamos Automotive Simulator
00002 //  Copyright (C) 2001--2002 Sam Varner
00003 //
00004 //  This program is free software; you can redistribute it and/or modify
00005 //  it under the terms of the GNU General Public License as published by
00006 //  the Free Software Foundation; either version 2 of the License, or
00007 //  (at your option) any later version.
00008 //
00009 //  This program is distributed in the hope that it will be useful,
00010 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 //  GNU General Public License for more details.
00013 //
00014 //  You should have received a copy of the GNU General Public License
00015 //  along with this program; if not, write to the Free Software
00016 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 #ifndef _INERTIA_TENSOR_H_
00019 #define _INERTIA_TENSOR_H_
00020 
00021 #include <vamos/geometry/Three_Matrix.h>
00022 #include <vamos/geometry/Three_Vector.h>
00023 
00024 namespace Vamos_Geometry
00025 {
00026   // Exception class thrown if the inertia tensor is singular.
00027   class Bad_Inertia_Tensor {};
00028 
00029   // Inertia_Tensor describes the inertia tensor for a rigid body.
00030   class Inertia_Tensor : public Three_Matrix
00031   {
00032         // The total mass of all components.
00033         double m_mass;
00034         // The inverse of the inertia tensor.
00035         Three_Matrix m_inverse;
00036 
00037   public:
00038         // The constructor is trivial.
00039         
00040         // Add a mass to the system at `position'.  The inertia tensor
00041         // components are calculated here.
00042         void add (double mass, const Three_Vector& position);
00043 
00044         // Zero the components of the inertia tensor and also the mass.
00045         void zero ();
00046 
00047         // Calculate the inverse of the inertia tensor.  If the tensor is
00048         // singular, Bad_Inertia_Tensor is thrown.  update() must be
00049         // called after all add()s have been performed.
00050         void update ();
00051         
00052         // Return the moment of inertia for a force applied at POSITION in
00053         // the direction FORCE_DIRECTION.  FORCE_DIRECTION need not be a
00054         // unit vector.
00055         double inertia (const Three_Vector& position,
00056                                         const Three_Vector& force_direction) const;
00057 
00058         // Return the moment of inertia for TORQUE applied to the center
00059         // of mass.  TORQUE need not be a unit vector.
00060         double inertia (const Three_Vector& torque) const;
00061 
00062         // Return the inverse of the inertia tensor.
00063         const Three_Matrix& inverse () const { return m_inverse; }
00064   };
00065 }
00066 
00067 #endif

Generated on Thu Oct 19 04:05:47 2006 by  doxygen 1.4.6