|
rigidbod.h00001 /* 00002 Dynamics/Kinematics modeling and simulation library. 00003 Copyright (C) 1999 by Michael Alexander Ewert 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 00019 */ 00020 00021 #ifndef __CT_RIGIDBODY_H__ 00022 #define __CT_RIGIDBODY_H__ 00023 00024 #include "csphyzik/phyzent.h" 00025 #include "csphyzik/phyztype.h" 00026 00027 #define RBSTATESIZE (6 + PHYSICALENTITY_STATESIZE) 00028 struct iObjectRegistry; 00029 00031 class ctRigidBody : public ctDynamicEntity 00032 { 00033 public: 00034 /* 00035 ** Constructors/destructors/statics 00036 */ 00037 ctRigidBody(); 00038 ctRigidBody( ctReferenceFrame &ref, ctDeltaReferenceFrame &dref ); 00039 // ctRigidBody( ctReferenceFrame &ref, ); 00040 virtual ~ctRigidBody(); 00041 00043 static ctRigidBody *new_ctRigidBody (); 00045 static ctRigidBody *new_ctRigidBody ( coord x, coord y, coord z ); 00047 static int get_RB_state_size () 00048 { return RBSTATESIZE; } 00049 00050 00051 iObjectRegistry *object_reg; 00052 00053 /* 00054 ** Member functions 00055 */ 00060 void calc_simple_I_tensor( real width, real height, real depth ); 00061 00063 const ctMatrix3 &get_I () 00064 { return I; } 00065 00067 const ctMatrix3 &get_I_inv () 00068 { return I_inv; } 00069 00070 /* 00071 ctMatrix3 get_I_inv_world(){ 00072 const ctMatrix3 &R = RF.get_R(); 00073 ctMatrix3 I_inv_world = R * I_inv * (R.get_transpose()); 00074 return I_inv_world; 00075 } 00076 00077 ctMatrix3 get_I_world(){ 00078 const ctMatrix3 &R = RF.get_R(); 00079 ctMatrix3 I_world = R * I * (R.get_transpose()); 00080 return I_world; 00081 } 00082 */ 00083 00084 ctMatrix3 get_I_inv_world () 00085 { 00086 const ctMatrix3 &R = RF.get_R(); 00087 ctMatrix3 I_inv_world; 00088 R.similarity_transform( I_inv_world, I_inv ); 00089 return I_inv_world; 00090 } 00091 00092 ctMatrix3 get_I_world () 00093 { 00094 const ctMatrix3 &R = RF.get_R(); 00095 ctMatrix3 I_world; 00096 R.similarity_transform( I_world, I ); 00097 return I_world; 00098 } 00099 00100 /* 00101 virtual ctMatrix3 get_impulse_I_inv(){ 00102 // return get_I_inv_world(); 00103 const ctMatrix3 &R = RF.get_R(); 00104 ctMatrix3 Mret; 00105 R.similarity_transform( Mret, I_inv ); 00106 return Mret; 00107 } 00108 */ 00109 00110 virtual void get_impulse_m_and_I_inv ( real *pm, ctMatrix3 *pI_inv, 00111 const ctVector3 &impulse_point, const ctVector3 &unit_length_impulse_vector ) 00112 { 00113 (void)unit_length_impulse_vector; 00114 (void)impulse_point; 00115 *pm = m; 00116 const ctMatrix3 &R = RF.get_R(); 00117 R.similarity_transform( *pI_inv, I_inv ); 00118 } 00119 00121 ctVector3 get_angular_P () 00122 { return L; } 00123 00124 ctVector3 get_P () 00125 { return P; } 00126 00128 virtual int get_state_size () { return RBSTATESIZE; } 00129 virtual int set_state ( real *state_array ); 00130 virtual int get_state ( const real *state_array ); 00131 virtual int set_delta_state ( real *state_array ); 00132 virtual void set_angular_v ( const ctVector3 &pw ); 00133 virtual void set_v ( const ctVector3 &pv ); 00134 virtual void add_angular_v ( const ctVector3 &pw ); 00135 virtual void add_v ( const ctVector3 &pv ); 00136 virtual void set_m ( real pm ); 00137 00142 virtual void apply_impulse( ctVector3 impulse_point, ctVector3 impulse_vector ); 00143 00144 protected: 00146 ctVector3 P; 00148 ctVector3 L; 00150 ctMatrix3 I; 00152 ctMatrix3 I_inv; 00153 00154 }; 00155 00156 #endif // __CT_RIGIDBODY_H__ Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000 |