Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Apr 14, 2005, 12:21:27 AM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: most important often used functions inlined

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

Legend:

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

    r3818 r3819  
    2323#include "vector.h"
    2424#include "debug.h"
    25 #include "stdincl.h"
    2625
    2726using namespace std;
     
    9089        \return the cross product of the vectors
    9190*/
    92 Vector Vector::cross (const Vector& v) const
    93 {
    94   return Vector(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x );
    95 }
     91//Vector Vector::cross (const Vector& v) const
     92
    9693 
    9794/**
    9895   \brief normalizes the vector to lenght 1.0
    9996*/
    100 void Vector::normalize ()
    101 {
    102   float l = len();
    103  
    104   __UNLIKELY_IF( l == 0.0)
    105   {
    106     // Prevent divide by zero
    107     return;
    108   }
    109  
    110   x = x / l;
    111   y = y / l;
    112   z = z / l;
    113 }
     97//void Vector::normalize ()
    11498
    11599
     
    149133   \return the lenght of the vector
    150134*/
    151 float Vector::len () const
    152 {
    153   return sqrt (x*x+y*y+z*z);
    154 }
     135//float Vector::len () const
    155136
    156137
  • orxonox/trunk/src/lib/math/vector.h

    r3818 r3819  
    1010
    1111#include <math.h>
     12#include "stdincl.h"
    1213//! PI the circle-constant
    1314#define PI 3.14159265359f
     
    3031
    3132  inline Vector operator+ (const Vector& v) const { return Vector(x + v.x, y + v.y, z + v.z); }
    32   Vector operator- (const Vector& v) const { return Vector(x - v.x, y - v.y, z - v.z); }
    33   float operator* (const Vector& v) const { return x * v.x + y * v.y + z * v.z; }
    34   Vector operator* (float f) const { return Vector(x * f, y * f, z * f); }
     33  inline Vector operator- (const Vector& v) const { return Vector(x - v.x, y - v.y, z - v.z); }
     34  inline float operator* (const Vector& v) const { return x * v.x + y * v.y + z * v.z; }
     35  inline Vector operator* (float f) const { return Vector(x * f, y * f, z * f); }
    3536  Vector operator/ (float f) const;
    3637  float dot (const Vector& v) const;
    37   Vector cross (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 ); }
    3839  void scale(const Vector& v);
    39   float len() const;
    40   void normalize();
     40  inline float len() const { return sqrt (x*x+y*y+z*z); }
     41  inline void normalize() {
     42                      float l = len();
     43                      __UNLIKELY_IF( l == 0.0)
     44                        {
     45                          // Prevent divide by zero
     46                          return;
     47                        }
     48                      x = x / l;
     49                      y = y / l;
     50                      z = z / l;
     51                    }
    4152  Vector* getNormalized();
    4253  Vector abs();
Note: See TracChangeset for help on using the changeset viewer.