RK4.h

00001 
00002 //    Copyright 2004, SenseGraphics AB
00003 //
00004 //    This file is part of H3D API.
00005 //
00006 //    H3D API is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    H3D API is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with H3D API; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 //
00020 //    A commercial license is also available. Please contact us at 
00021 //    www.sensegraphics.com for more information.
00022 //
00023 //
00024 //
00027 //
00029 #ifndef __RK4_H__
00030 #define __RK4_H__
00031 
00032 #include "H3DTypes.h"
00033 
00034 using namespace std;
00035 
00036 namespace H3D {
00037 
00038   struct DvState {
00039     // linear state:
00040     Vec3f vel;
00041     Vec3f force;
00042 
00043     // angular state:
00044     Quaternion spin;
00045     Vec3f torque;
00046   };
00047 
00048   struct LMState {
00049     // linear state:
00050     Vec3f pos;
00051     Vec3f mom;
00052     Vec3f vel;
00053     Vec3f force;
00054 
00055     // angular state:
00056     Quaternion orn;
00057     Quaternion spin;
00058     Vec3f angMom;
00059     Vec3f angVel;
00060     Matrix3f inertiaTensor;
00061     Vec3f torque;
00062 
00063     // constants:
00064     float mass;
00065   };
00066 
00067   // Performs fourth-order Runge Kutta integration for solving
00068   // linear motion of a rigid body.
00069   struct LinearMotion {
00070 
00071     static void update( LMState &state );
00072 
00073     static DvState evaluate( LMState state );
00074 
00075     static DvState evaluate( LMState state, H3DTime dt, DvState start );
00076 
00077     static void solve( LMState &state, H3DTime dt );
00078     
00079   };
00080 
00081 
00082 };
00083 
00084 #endif

Generated on Thu Aug 24 12:38:34 2006 for H3D API by  doxygen 1.4.5