Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4221 in orxonox.OLD for orxonox


Ignore:
Timestamp:
May 19, 2005, 1:28:19 AM (20 years ago)
Author:
buerlia
Message:

orxonox/branches/physics: addForce function for rigid bodies; made some small functions inline

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  
    3434   this->mass = 0;
    3535   this->massChildren = 0;
     36   this->forceSum = Vector(0, 0, 0);
    3637}
    3738
     
    4445{
    4546  // 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 ) const
    56 {
    57         return this->mass;
    58 }
    59 
    60 float IPhysics::getTotalMass( void ) const
    61 {
    62         return (this->mass + this->massChildren);
    6347}
    6448
     
    8973       
    9074       
     75void IPhysics::addForce( Vector force )
     76{
     77        forceSum += force;
     78}
     79
     80void IPhysics::addForce(Vector force, Vector grip)
     81{
     82        // add central force
     83        forceSum += force;
     84        // add momentum
     85        // todo: some vector math
     86}
     87       
     88void 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  
    1919  virtual ~IPhysics();
    2020 
    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
    2427
    2528 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
    3034
    3135 private:
Note: See TracChangeset for help on using the changeset viewer.