Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4178 in orxonox.OLD for orxonox/branches/physics/src/lib/coord


Ignore:
Timestamp:
May 13, 2005, 11:16:33 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/physics: merged the Trunk into the physics Branche again:
merged with command:
svn merge ../trunk physics -r 3953:HEAD
no important conflicts

Location:
orxonox/branches/physics
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/physics

    • Property svn:externals
      •  

        old new  
        1 data http://svn.orxonox.ethz.ch/data
         1
  • orxonox/branches/physics/src/lib/coord/null_parent.cc

    r3809 r4178  
    5454  this->parent = this;
    5555  this->mode = PNODE_ALL;
    56   *this->absCoordinate = absCoordinate;
     56  this->absCoordinate = absCoordinate;
    5757  this->setName("NullParent");
    5858}
     
    8080{
    8181
    82   PRINTF(4)("NullParent::update - (%f, %f, %f)\n", this->absCoordinate->x, this->absCoordinate->y, this->absCoordinate->z);
    83   *this->absCoordinate = *this->relCoordinate;
    84   *this->absDirection = parent->getAbsDir () * *this->relDirection;
     82  PRINTF(4)("NullParent::update - (%f, %f, %f)\n", this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
     83  this->absCoordinate = this->relCoordinate;
     84  this->absDirection = parent->getAbsDir () * this->relDirection;
    8585
    8686  tIterator<PNode>* iterator = this->children->getIterator();
  • orxonox/branches/physics/src/lib/coord/p_node.cc

    r3860 r4178  
    6060  this->init(parent);
    6161
    62   *this->absCoordinate = absCoordinate;
     62  this->absCoordinate = absCoordinate;
    6363
    6464  if (likely(parent != NULL))
    6565  {
    66     *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();
     66    this->relCoordinate = this->absCoordinate - parent->getAbsCoor();
    6767    parent->addChild (this);
    6868  }
    69   else
    70     this->relCoordinate = new Vector();
    7169}
    7270
     
    8987  delete []this->objectName;
    9088
    91   delete this->relCoordinate;
    92   delete this->absCoordinate;
    93   delete this->relDirection;
    94   delete this->absDirection;
    95   delete this->lastAbsCoordinate;
    96   delete this->diffCoordinate;
    9789}
    9890
     
    10799  this->parent = parent;
    108100  this->objectName = NULL;
    109   this->time = 1.0; /* set time to 1 to make divisions by zero impossible */
    110 
    111   this->absCoordinate = new Vector();
    112   this->relCoordinate = new Vector();
    113   this->absDirection = new Quaternion();
    114   this->relDirection = new Quaternion();
    115   this->lastAbsCoordinate = new Vector();
    116   this->diffCoordinate = new Vector();
    117101}
    118102
     
    158142{
    159143  this->bRelCoorChanged = true;
    160   *this->relCoordinate = relCoord;
     144  this->relCoordinate = relCoord;
    161145}
    162146
     
    182166{
    183167  this->bAbsCoorChanged = true;
    184   *this->absCoordinate = absCoord;
     168  this->absCoordinate = absCoord;
    185169}
    186170
     
    211195  if( unlikely(this->bAbsCoorChanged))
    212196    {
    213       *this->absCoordinate = *this->absCoordinate + shift;
     197      this->absCoordinate += shift;
    214198    }
    215199  else
    216200    {
    217       *this->relCoordinate = *this->relCoordinate + shift;
     201      this->relCoordinate += shift;
    218202      this->bRelCoorChanged = true;
    219203    }
     
    241225{
    242226  this->bRelCoorChanged = true;
    243   *this->relDirection = relDir;
     227  this->relDirection = relDir;
    244228}
    245229
     
    264248{
    265249  this->bAbsDirChanged = true;
    266   *this->absDirection = absDir;
     250  this->absDirection = absDir;
    267251}
    268252
     
    293277{
    294278  this->bRelDirChanged = true;
    295   *this->relDirection = *this->relDirection * shift;
    296 }
    297 
    298 
    299 
    300 /**
    301    \brief this calculates the current movement speed of the node
    302 */
    303 float PNode::getSpeed() const
    304 {
    305   *this->diffCoordinate = *this->absCoordinate - *this->lastAbsCoordinate;
    306   return this->diffCoordinate->len() / this->time;
    307 }
    308 
     279  this->relDirection = this->relDirection * shift;
     280}
    309281
    310282/**
     
    432404void PNode::update (float dt)
    433405{
    434   *this->lastAbsCoordinate = *this->absCoordinate;
    435   this->time = dt;
    436   PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate->x, this->absCoordinate->y, this->absCoordinate->z);
     406  this->lastAbsCoordinate = this->absCoordinate;
     407
     408  PRINTF(4)("PNode::update - %s - (%f, %f, %f)\n", this->objectName, this->absCoordinate.x, this->absCoordinate.y, this->absCoordinate.z);
    437409
    438410
     
    442414        {
    443415          /* if you have set the absolute coordinates this overrides all other changes */
    444           *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();
     416          this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
    445417        }
    446418      if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
     
    455427            }
    456428            else */
    457           *this->absCoordinate = parent->getAbsCoor() + *this->relCoordinate;         /* update the current absCoordinate */
     429          this->absCoordinate = parent->getAbsCoor() + this->relCoordinate;           /* update the current absCoordinate */
    458430        }
    459431    }
     
    464436        {
    465437          /* if you have set the absolute coordinates this overrides all other changes */
    466           *this->relDirection = *this->absDirection - parent->getAbsDir();
     438          this->relDirection = this->absDirection - parent->getAbsDir();
    467439        }
    468440      else if( likely(this->bRelDirChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
    469441        {
    470442          /* update the current absDirection - remember * means rotation around sth.*/
    471           *this->absDirection = parent->getAbsDir() * *this->relDirection;
     443          this->absDirection = parent->getAbsDir() * this->relDirection;
    472444        }
    473445    }
     
    478450        {
    479451          /* if you have set the absolute coordinates this overrides all other changes */
    480           *this->relCoordinate = *this->absCoordinate - parent->getAbsCoor ();
     452          this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
    481453        }
    482454      else if( likely(this->bRelCoorChanged) /*&& this->timeStamp != DataTank::timeStamp*/)
     
    486458            *this->absCoordinate = *this->relCoordinate;
    487459            else*/
    488           *this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(*this->relCoordinate);              /* update the current absCoordinate */
     460          this->absCoordinate = parent->getAbsCoor() + parent->getAbsDir().apply(this->relCoordinate);        /* update the current absCoordinate */
    489461        }
    490462    }
     
    508480  delete iterator;
    509481
     482  this->velocity = (this->absCoordinate - this->lastAbsCoordinate) / dt;
    510483  this->timeStamp = timeStamp;
    511484  this->bRelCoorChanged = false;
     
    540513{
    541514  PRINTF(2)("PNode::debug() - absCoord: (%f, %f, %f)\n",
    542          this->absCoordinate->x,
    543          this->absCoordinate->y,
    544          this->absCoordinate->z);
     515         this->absCoordinate.x,
     516         this->absCoordinate.y,
     517         this->absCoordinate.z);
    545518}
    546519
     
    551524  for debug purposes realy usefull, not used to work properly
    552525*/
    553 void PNode::setName (char* newName)
     526void PNode::setName (const char* newName)
    554527{
    555528  this->objectName = new char[strlen(newName)+1];
     
    561534  \brief gets the name of the node
    562535*/
    563 char* PNode::getName ()
     536const char* PNode::getName ()
    564537{
    565538  return this->objectName;
  • orxonox/branches/physics/src/lib/coord/p_node.h

    r3813 r4178  
    5757
    5858
    59   inline Vector* getRelCoor () const { return this->relCoordinate; }
     59  inline const Vector& getRelCoor () const { return this->relCoordinate; }
    6060  void setRelCoor (const Vector& relCoord);
    61   inline Vector getAbsCoor () const { return *this->absCoordinate; }
     61  inline const Vector& getAbsCoor () const { return this->absCoordinate; }
    6262  void setAbsCoor (const Vector& absCoord);
    6363  void shiftCoor (const Vector& shift);
    6464
    65   inline Quaternion getRelDir () const { return *this->relDirection; }
     65  inline const Quaternion& getRelDir () const { return this->relDirection; }
    6666  void setRelDir (const Quaternion& relDir);
    67   inline Quaternion getAbsDir () const { return *this->absDirection; }
     67  inline const Quaternion& getAbsDir () const { return this->absDirection; }
    6868  void setAbsDir (const Quaternion& absDir);
    6969  void shiftDir (const Quaternion& shift);
    7070
    71   float getSpeed() const;
     71  /** \returns the Speed of the Node */
     72  inline float getSpeed() const {return this->velocity.len()/1000;} //! \FIX THIS SHOULD NOT BE /1000
     73  /** \returns the Velocity of the Node */
     74  inline const Vector& getVelocity() const {return this->velocity;}
    7275
    7376  void addChild (PNode* pNode, int parentingMode = DEFAULT_MODE);
     
    8588  void processTick (float dt);
    8689
    87   void setName (char* newName);
    88   char* getName ();
     90  void setName (const char* newName);
     91  const char* getName ();
    8992
    9093
     
    99102  bool bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
    100103
    101   Vector* relCoordinate;    //!< coordinates relative to the parent
    102   Vector* absCoordinate;    //!< absolute coordinates in the world ( from (0,0,0) )
    103   Quaternion* relDirection; //!< direction relative to the parent
    104   Quaternion* absDirection; //!< absolute direvtion in the world ( from (0,0,1) )
     104  Vector relCoordinate;    //!< coordinates relative to the parent
     105  Vector absCoordinate;    //!< absolute coordinates in the world ( from (0,0,0) )
     106  Quaternion relDirection; //!< direction relative to the parent
     107  Quaternion absDirection; //!< absolute direvtion in the world ( from (0,0,1) )
    105108
    106109  int mode;                //!< the mode of the binding
     
    109112  void init(PNode* parent);
    110113
    111   Vector* lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate
    112   Vector* diffCoordinate;    //!< this is stored here for performance reasons, difference to the last vector
    113   float time;                //!< time since last update
     114  Vector velocity;          //!< Saves the velocity.
     115  Vector lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate
    114116};
    115117
Note: See TracChangeset for help on using the changeset viewer.