Changeset 3819 in orxonox.OLD for orxonox/trunk/src/lib/math
- Timestamp:
- Apr 14, 2005, 12:21:27 AM (20 years ago)
- Location:
- orxonox/trunk/src/lib/math
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/math/vector.cc
r3818 r3819 23 23 #include "vector.h" 24 24 #include "debug.h" 25 #include "stdincl.h"26 25 27 26 using namespace std; … … 90 89 \return the cross product of the vectors 91 90 */ 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 96 93 97 94 /** 98 95 \brief normalizes the vector to lenght 1.0 99 96 */ 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 () 114 98 115 99 … … 149 133 \return the lenght of the vector 150 134 */ 151 float Vector::len () const 152 { 153 return sqrt (x*x+y*y+z*z); 154 } 135 //float Vector::len () const 155 136 156 137 -
orxonox/trunk/src/lib/math/vector.h
r3818 r3819 10 10 11 11 #include <math.h> 12 #include "stdincl.h" 12 13 //! PI the circle-constant 13 14 #define PI 3.14159265359f … … 30 31 31 32 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); } 35 36 Vector operator/ (float f) const; 36 37 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 ); } 38 39 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 } 41 52 Vector* getNormalized(); 42 53 Vector abs();
Note: See TracChangeset
for help on using the changeset viewer.