include/vamos/body/Particle.h

Go to the documentation of this file.
00001 //      Particle.h - a massive particle which is part of a rigid body.
00002 //
00003 //  Copyright (C) 2001--2002 Sam Varner
00004 //
00005 //  This file is part of Vamos Automotive Simulator.
00006 //
00007 //  This program is free software; you can redistribute it and/or modify
00008 //  it under the terms of the GNU General Public License as published by
00009 //  the Free Software Foundation; either version 2 of the License, or
00010 //  (at your option) any later version.
00011 //
00012 //  This program is distributed in the hope that it will be useful,
00013 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 //  GNU General Public License for more details.
00016 //
00017 //  You should have received a copy of the GNU General Public License
00018 //  along with this program; if not, write to the Free Software
00019 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021 #ifndef _PARTICLE_H_
00022 #define _PARTICLE_H_
00023 
00024 #include <vamos/geometry/Three_Vector.h>
00025 #include <vamos/geometry/Three_Matrix.h>
00026 #include <vamos/geometry/Inertia_Tensor.h>
00027 #include <vamos/geometry/Material.h>
00028 #include <vamos/body/Frame.h>
00029 #include <vamos/body/Exerter.h>
00030 
00031 namespace Vamos_Body
00032 {
00033   //* A Particle is a massive particle which is part of a rigid body.
00034   // It has position and orientation information inherited from Frame.
00035   // The parent frame is the rigid body's.  A Particle can exert
00036   // forces and torques on the rigid body because it is derived from
00037   // Component.
00038   class Particle : public Frame, public Exerter
00039   {
00040   protected:
00041         // The mass of the particle.
00042         double m_mass;
00043 
00044         // Material properties for the particle.
00045         Vamos_Geometry::Material_Handle m_material;
00046 
00047   public:
00048         //** Constructors
00049 
00050         // Specify position and orientation.
00051         Particle (double mass, const Vamos_Geometry::Three_Vector& position, 
00052                           const Vamos_Geometry::Three_Matrix& orientation);
00053 
00054         // Take the parent's orientation.
00055         Particle (double mass, const Vamos_Geometry::Three_Vector& position);
00056 
00057         // The particle's frame is coincident with the parent's.
00058         Particle (double mass = 0.0);
00059 
00060         //** Destructor
00061         virtual ~Particle () {};
00062 
00063         // Return the force exerted on the rigid body in the body's frame.
00064         virtual Vamos_Geometry::Three_Vector force () const
00065         { return rotate_out (m_force); }
00066 
00067         // Return the impulse exerted on the rigid body in the body's
00068         // frame.
00069         virtual Vamos_Geometry::Three_Vector impulse () const
00070         { return rotate_out (m_impulse); }
00071 
00072         // Return the torque exerted on the rigid body in the body's frame.
00073         virtual Vamos_Geometry::Three_Vector torque () const
00074         { return rotate_out (m_torque); }
00075 
00076         // Classes derived from Particle may lie about their positions
00077         // for collisions...
00078         virtual Vamos_Geometry::Three_Vector contact_position () const 
00079         { return position (); }
00080 
00081         // ...for exerting forces and impulses...
00082         virtual Vamos_Geometry::Three_Vector force_position () const 
00083         { return position (); }
00084 
00085         // ...for exerting torques...
00086         virtual Vamos_Geometry::Three_Vector torque_position () const 
00087         { return position (); }
00088 
00089         // ...or for constructing the inertia tensor of the rigid body.
00090         virtual Vamos_Geometry::Three_Vector mass_position () const 
00091         { return position (); }
00092 
00093         virtual double contact (const Vamos_Geometry::Three_Vector& position,
00094                                                         const Vamos_Geometry::Inertia_Tensor& inertia,
00095                                                         const Vamos_Geometry::Three_Vector& velocity,
00096                                                         double distance,
00097                                                         const Vamos_Geometry::Three_Vector& normal,
00098                                                         const Vamos_Geometry::Three_Vector& ang_velocity,
00099                                                         Vamos_Geometry::Material_Handle) 
00100         { return 0.0; }
00101 
00102         // Return the particle's mass.
00103         double mass () const { return m_mass; }
00104 
00105         virtual bool single_contact () const { return true; }
00106         virtual void wind (const Vamos_Geometry::Three_Vector& wind_vector, 
00107                                            double density) 
00108         {};
00109 
00110         // Return the material properties.
00111         const Vamos_Geometry::Material_Handle& material () const 
00112         { return m_material; }
00113   };
00114 }
00115 
00116 #endif // not _PARTICLE_H_

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