- Timestamp:
- May 19, 2005, 1:28:19 AM (20 years ago)
- Location:
- orxonox/branches/physics/src/util/physics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/branches/physics/src/util/physics/i_physics.cc
r4121 r4221 34 34 this->mass = 0; 35 35 this->massChildren = 0; 36 this->forceSum = Vector(0, 0, 0); 36 37 } 37 38 … … 44 45 { 45 46 // delete what has to be deleted here 46 }47 48 49 50 void IPhysics::setMass( float mass )51 {52 this->mass = mass;53 }54 55 float IPhysics::getMass( void ) const56 {57 return this->mass;58 }59 60 float IPhysics::getTotalMass( void ) const61 {62 return (this->mass + this->massChildren);63 47 } 64 48 … … 89 73 90 74 75 void IPhysics::addForce( Vector force ) 76 { 77 forceSum += force; 78 } 79 80 void IPhysics::addForce(Vector force, Vector grip) 81 { 82 // add central force 83 forceSum += force; 84 // add momentum 85 // todo: some vector math 86 } 87 88 void IPhysics::tick( float dt ) 89 { 90 Vector acc = forceSum / ( massChildren + mass ); 91 // todo: introduce kinematics 92 } -
orxonox/branches/physics/src/util/physics/i_physics.h
r4121 r4221 19 19 virtual ~IPhysics(); 20 20 21 void setMass( float mass ); //!< Set the mass of this node 22 float getMass( void ) const; //!< Get the mass of this node 23 float getTotalMass( void ) const; //!< Get the sum of the masses of this node and all subnodes 21 inline void setMass( float mass ) { this->mass = mass; }; //!< Set the mass of this node 22 inline float getMass( void ) const { return mass; }; //!< Get the mass of this node 23 inline float getTotalMass( void ) const { return mass + massChildren; }; //!< Get the sum of the masses of this node and all subnodes 24 void addForce( Vector force ); //!< Add a central force on this rigid body 25 void addForce( Vector force, Vector grip ); //!< Add a decentral force on this rigid body 26 void tick( float dt ); //!< Update kinematics, reset force sum 24 27 25 28 protected: 26 void recalcMass(); //!< Recalculate the mass of the children 27 float mass; //!< Mass of this node 28 float massChildren; //!< Sum of the masses of the children nodes 29 29 void recalcMass(); //!< Recalculate the mass of the children 30 float mass; //!< Mass of this node 31 float massChildren; //!< Sum of the masses of the children nodes 32 Vector forceSum; //!< Total central force for this tick 33 Quaternion momentumSum; //!< Total momentum in this tick 30 34 31 35 private:
Note: See TracChangeset
for help on using the changeset viewer.