src/vamos/body/Aerodynamic_Device.cc

Go to the documentation of this file.
00001 //  Aerodynamic_Device.cc - a particle that produces drag and lift.
00002 //
00003 //  Copyright (C) 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 #include <vamos/body/Aerodynamic_Device.h>
00022 #include <vamos/geometry/Constants.h>
00023 #include <cmath>
00024 
00025 using namespace Vamos_Geometry;
00026 
00027 //* Class Aerodynamic_Device
00028 
00029 //** Constructor
00030 Vamos_Body::
00031 Aerodynamic_Device::Aerodynamic_Device (const Three_Vector& position) :
00032   Particle (0.0, position)
00033 {
00034 }
00035 
00036 // Calculate the drag and lift due to WIND_VECTOR.  WIND_VECTOR is
00037 // supplied by the Body in the Body's frame.
00038 void Vamos_Body::
00039 Aerodynamic_Device::wind (const Three_Vector& wind_vector, double density)
00040 {
00041   m_wind_vector = wind_vector;
00042   m_density = density;
00043 }
00044 
00045 //-----------------------------------------------------------------------------
00046 //* Class Drag
00047 
00048 //** Constructor
00049 Vamos_Body::
00050 Drag::Drag (const Three_Vector& position,
00051                         double frontal_area, double drag_coefficient) :
00052   Aerodynamic_Device (position),
00053   m_frontal_area (frontal_area),
00054   m_drag_coefficient (drag_coefficient)
00055 {
00056 }
00057 
00058 // Find and store the forces, impulses, and torques for the current
00059 // configuration.
00060 void Vamos_Body::
00061 Drag::find_forces ()
00062 {
00063   // Calculate the drag and lift forces.
00064   m_force = 0.5 * m_density * m_drag_coefficient * m_frontal_area
00065         * m_wind_vector * m_wind_vector.abs ();
00066 }
00067 
00068 //-----------------------------------------------------------------------------
00069 //* Class Wing
00070 
00071 //** Constructor
00072 Vamos_Body::
00073 Wing::Wing (const Three_Vector& position,
00074                         double frontal_area, double drag_coefficient,
00075                         double surface_area, double lift_coefficient,
00076                         double efficiency) :
00077   Drag (position, frontal_area, drag_coefficient),
00078   m_surface_area (surface_area),
00079   m_lift_coefficient (lift_coefficient),
00080   m_efficiency (efficiency)
00081 {
00082 }
00083 
00084 // Find and store the forces, impulses, and torques for the current
00085 // configuration.
00086 void Vamos_Body::
00087 Wing::find_forces ()
00088 {
00089   Drag::find_forces ();
00090 
00091   const double wind_speed = std::abs (m_wind_vector.dot (Three_Vector::X));
00092   const double k = 0.5 * m_density * wind_speed * wind_speed;
00093   double lift = k * m_lift_coefficient * m_surface_area;
00094   double drag = -m_lift_coefficient * lift * (1.0 -  m_efficiency);
00095 
00096   m_force += Three_Vector (drag, 0.0, lift);
00097 }

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