Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3958 in orxonox.OLD for orxonox/branches/particleEngine/src


Ignore:
Timestamp:
Apr 25, 2005, 2:49:51 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/particleEngine: some more functionality to the vectors-class

Location:
orxonox/branches/particleEngine/src/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/particleEngine/src/lib/coord/p_node.h

    r3957 r3958  
    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);
  • orxonox/branches/particleEngine/src/lib/graphics/particles/particle_emitter.cc

    r3951 r3958  
    134134        randDir.normalize();
    135135        randDir = (this->getAbsDir()*Quaternion(angle + randomAngle *((float)random()/RAND_MAX -.5), randDir)).apply(this->direction);
    136         randDir = *randDir.getNormalized()*velocity + (this->getVelocity() * system->inheritSpeed);
     136        randDir = randDir.getNormalized()*velocity + (this->getVelocity() * system->inheritSpeed);
    137137
    138138        system->addParticle(this->getAbsCoor(), randDir);
  • orxonox/branches/particleEngine/src/lib/math/vector.cc

    r3951 r3958  
    100100*/
    101101
    102 Vector* Vector::getNormalized()
     102const Vector Vector::getNormalized()
    103103{
    104104  float l = len();
    105105  if(unlikely(l != 1.0))
    106106    {
    107       return this;
     107      return *this;
    108108    }
    109109  else if(unlikely(l == 0.0))
    110110    {
    111       return 0;
     111      return Vector();
    112112    }
    113113
    114   return new Vector(x / l, y /l, z / l);
     114  return Vector(x / l, y /l, z / l);
    115115}
    116116
  • orxonox/branches/particleEngine/src/lib/math/vector.h

    r3951 r3958  
    3131
    3232  inline Vector operator+ (const Vector& v) const { return Vector(x + v.x, y + v.y, z + v.z); }
     33  inline const Vector operator+= (const Vector& v) {this->x += v.x; this->y += v.y; this->z += v.z; return *this;}
    3334  inline Vector operator- (const Vector& v) const { return Vector(x - v.x, y - v.y, z - v.z); }
     35  inline const Vector operator-= (const Vector& v) {this->x -= v.x; this->y -= v.y; this->z -= v.z; return *this;}
    3436  inline float operator* (const Vector& v) const { return x * v.x + y * v.y + z * v.z; }
     37  inline const Vector operator*= (const Vector& v) {this->x *= v.x; this->y *= v.y; this->z *= v.z; return *this;}
    3538  inline Vector operator* (float f) const { return Vector(x * f, y * f, z * f); }
     39  inline const Vector operator*= (float f) {this->x *= f; this->y *= f; this->z *= f; return *this;}
    3640  Vector operator/ (float f) const;
     41  inline const Vector operator/= (float f) {this->x /= f; this->y /= f; this->z /= f; return *this;}
    3742  float dot (const Vector& v) const;
    38   inline Vector cross (const Vector& v) const {  return Vector(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x ); }
     43  inline Vector cross (const Vector& v) const { return Vector(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x ); }
    3944  void scale(const Vector& v);
    4045  inline float len() const { return sqrt (x*x+y*y+z*z); }
     
    5055                      z = z / l;
    5156                    }
    52   Vector* getNormalized();
     57  const Vector getNormalized();
    5358  Vector abs();
    5459
Note: See TracChangeset for help on using the changeset viewer.