Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3595 in orxonox.OLD for orxonox/trunk/src/lib/math


Ignore:
Timestamp:
Mar 17, 2005, 5:44:56 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: deleted the UPOINTCURVE was very bad.
also deleted matrix.cc because of some license problems, and we do not need all the functions (and it can't even work with the vector-class

Location:
orxonox/trunk/src/lib/math
Files:
2 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/math/curve.cc

    r3593 r3595  
    2626
    2727#include "curve.h"
    28 #include "matrix.h"
     28
    2929#include "debug.h"
    3030
     
    285285  return curvePoint;
    286286}
    287 
    288 
    289 
    290 ///////////////////////////////////
    291 //// Uniform Point curve  /////////
    292 ///////////////////////////////////
    293 /**
    294    \brief Creates a new UPointCurve
    295 */
    296 UPointCurve::UPointCurve (void)
    297 {
    298   this->derivation = 0;
    299 }
    300 
    301 /**
    302    \brief Creates a new UPointCurve-Derivation-Curve of deriavation'th degree
    303 */
    304 UPointCurve::UPointCurve (int derivation)
    305 {
    306   this->derivation = derivation;
    307   dirCurve=NULL;
    308 }
    309 
    310 /**
    311    \brief Deletes a UPointCurve.
    312 
    313    It does this by freeing all the space taken over from the nodes
    314 */
    315 UPointCurve::~UPointCurve(void)
    316 {
    317   PathNode* tmpNode;
    318   currentNode = firstNode;
    319   while (tmpNode != 0)
    320     {
    321       tmpNode = currentNode;
    322       currentNode = currentNode->next;
    323       delete tmpNode;
    324     }
    325   if (dirCurve)
    326     delete dirCurve;
    327 }
    328 
    329 /**
    330    \brief Rebuilds a UPointCurve
    331    
    332    \todo very bad algorithm
    333 */
    334 void UPointCurve::rebuild(void)
    335 {
    336   // rebuilding the Curve itself
    337   PathNode* tmpNode = this->firstNode;
    338   int i=0;
    339   Matrix xTmpMat = Matrix(this->nodeCount, this->nodeCount);
    340   Matrix yTmpMat = Matrix(this->nodeCount, this->nodeCount);
    341   Matrix zTmpMat = Matrix(this->nodeCount, this->nodeCount);
    342   Matrix xValMat = Matrix(this->nodeCount, 3);
    343   Matrix yValMat = Matrix(this->nodeCount, 3);
    344   Matrix zValMat = Matrix(this->nodeCount, 3);
    345   while(tmpNode)
    346     {
    347       Vector fac = Vector(1,1,1);
    348       for (int j = 0; j < this->nodeCount; j++)
    349         {
    350           xTmpMat(i,j) = fac.x; fac.x *= (float)i/(float)this->nodeCount;//tmpNode->position.x;
    351           yTmpMat(i,j) = fac.y; fac.y *= (float)i/(float)this->nodeCount;//tmpNode->position.y;
    352           zTmpMat(i,j) = fac.z; fac.z *= (float)i/(float)this->nodeCount;//tmpNode->position.z;
    353         }
    354       xValMat(i,0) = tmpNode->position.x;
    355       yValMat(i,0) = tmpNode->position.y;
    356       zValMat(i,0) = tmpNode->position.z;
    357       ++i;
    358       tmpNode = tmpNode->next;
    359     }
    360   tmpNode = this->firstNode;
    361   xValMat = xTmpMat.Inv() *= xValMat;
    362   yValMat = yTmpMat.Inv() *= yValMat;
    363   zValMat = zTmpMat.Inv() *= zValMat;
    364   i = 0;
    365   while(tmpNode)
    366     {
    367       tmpNode->vFactor.x = xValMat(i,0);
    368       tmpNode->vFactor.y = yValMat(i,0);
    369       tmpNode->vFactor.z = zValMat(i,0);
    370 
    371       i++;
    372       tmpNode = tmpNode->next;
    373     }
    374 }
    375 
    376 /**
    377    \brief calculates the Position on the curve
    378    \param t The position on the Curve (0<=t<=1)
    379    \return the Position on the Path
    380 */
    381 Vector UPointCurve::calcPos(float t)
    382 {
    383   PathNode* tmpNode = firstNode;
    384   Vector ret = Vector(0.0,0.0,0.0);
    385   float factor = 1.0;
    386   while(tmpNode)
    387     {
    388       ret.x += tmpNode->vFactor.x * factor;
    389       ret.y += tmpNode->vFactor.y * factor;
    390       ret.z += tmpNode->vFactor.z * factor;
    391       factor *= t;
    392 
    393       tmpNode = tmpNode->next;
    394     }
    395   return ret;
    396 }
    397 
    398 /**
    399    \brief Calulates the direction of the Curve at time t.
    400    \param The time at which to evaluate the curve.
    401    \returns The vvaluated Vector.
    402 */
    403 Vector UPointCurve::calcDir (float t)
    404 {
    405   PathNode* tmpNode = firstNode;
    406   Vector ret = Vector(0.0,0.0,0.0);
    407   float factor = 1.0/t;
    408   int k=0;
    409   while(tmpNode)
    410     {
    411       ret.x += tmpNode->vFactor.x * factor *k;
    412       ret.y += tmpNode->vFactor.y * factor *k;
    413       ret.z += tmpNode->vFactor.z * factor *k;
    414       factor *= t;
    415       k++;
    416       tmpNode = tmpNode->next;
    417     }
    418   ret.normalize();
    419   return ret;
    420 }
    421 
    422 Vector UPointCurve::calcAcc (float t)
    423 {
    424 }
    425 
    426 /**
    427    \brief Calculates the Quaternion needed for our rotations
    428    \param t The time at which to evaluate the cuve.
    429    \returns The evaluated Quaternion.
    430 */
    431 Quaternion UPointCurve::calcQuat (float t)
    432 {
    433   return Quaternion (calcDir(t), Vector(0,0,1));
    434 }
    435 
    436 
    437 /**
    438   \brief returns the Position of the point calculated on the Curve
    439   \return a Vector to the calculated position
    440 */
    441 Vector UPointCurve::getPos(void) const
    442 {
    443   return curvePoint;
    444 }
  • orxonox/trunk/src/lib/math/curve.h

    r3588 r3595  
    1313
    1414//! An Enumerator that defines what sort of Curves are availible
    15 enum CurveType {BEZIERCURVE, UPOINTCURVE};
     15enum CurveType {BEZIERCURVE};
    1616
    1717
     
    9393};
    9494
    95 //! Uniform Point Curve-class
    96 /**
    97    A UPoint Curve is a A Curve, that flows through all the nodes given it.
    98    The Algorithm to buid the curve is rather slow, but Painting and tracing along the curve has high speed, so do not change this curve during the Game.
    99 
    100    This Curve is very erattic, so i do not recommend to use it.
    101 */
    102 class UPointCurve : public Curve
    103 {
    104  private:
    105   void rebuild(void);
    106  public:
    107   UPointCurve(void);
    108   UPointCurve(int derivation);
    109   ~UPointCurve(void);
    110 
    111   Vector calcPos(float t);
    112   Vector calcDir(float t);
    113   Vector calcAcc(float t);
    114   Quaternion calcQuat(float t);
    115  
    116   Vector getPos(void) const;
    117 };
    118 
    11995#endif /* _CURVE_H */
Note: See TracChangeset for help on using the changeset viewer.