Changeset 4476 in orxonox.OLD for orxonox/trunk/src/lib/math/vector.cc
- Timestamp:
- Jun 2, 2005, 4:03:50 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/math/vector.cc
r4372 r4476 25 25 26 26 /** 27 \brief add two vectors 28 \param v: the other vector 29 \return the sum of both vectors 30 */ 31 32 //Vector Vector::operator+ (const Vector& v) const 33 34 35 /** 36 \brief subtract a vector from another 37 \param v: the other vector 38 \return the difference between the vectors 39 */ 40 //Vector Vector::operator- (const Vector& v) const 41 42 43 /** 44 \brief calculate the dot product of two vectors 45 \param v: the other vector 46 \return the dot product of the vectors 47 */ 48 //float Vector::operator* (const Vector& v) const 49 50 51 /** 52 \brief multiply a vector with a float 53 \param f: the factor 54 \return the vector multipied by f 55 */ 56 //Vector Vector::operator* (float f) const 57 58 59 /** 60 \brief divide a vector with a float 61 \param f: the divisor 62 \return the vector divided by f 63 */ 64 Vector Vector::operator/ (float f) const 65 { 66 if( unlikely(f == 0.0)) 67 { 68 // Prevent divide by zero 69 return Vector (0,0,0); 70 } 71 return Vector(x / f, y / f, z / f); 72 } 73 74 /** 75 \brief calculate the dot product of two vectors 76 \param v: the other vector 77 \return the dot product of the vectors 78 */ 79 float Vector::dot (const Vector& v) const 80 { 81 return x*v.x+y*v.y+z*v.z; 82 } 83 84 /** 85 \brief calculate the cross product of two vectors 86 \param v: the other vector 87 \return the cross product of the vectors 88 */ 89 //Vector Vector::cross (const Vector& v) const 90 91 92 /** 93 \brief normalizes the vector to lenght 1.0 94 */ 95 //void Vector::normalize () 96 97 98 /** 99 \brief returns the voctor normalized to length 1.0 100 */ 101 27 \brief returns the this-vector normalized to length 1.0 28 */ 102 29 Vector Vector::getNormalized() const 103 30 { … … 114 41 return *this / l; 115 42 } 116 117 /**118 \brief scales this Vector with Vector v.119 \param v the vector to scale this vector with120 */121 void Vector::scale(const Vector& v)122 {123 x *= v.x;124 y *= v.y;125 z *= v.z;126 }127 128 129 /**130 \brief calculates the lenght of the vector131 \return the lenght of the vector132 */133 //float Vector::len () const134 135 136 /**137 \brief Vector is looking in the positive direction on all axes after this138 */139 Vector Vector::abs()140 {141 Vector v(fabs(x), fabs(y), fabs(z));142 return v;143 }144 145 /**146 \brief calculate the angle between two vectors in radiances147 \param v1: a vector148 \param v2: another vector149 \return the angle between the vectors in radians150 */151 float angleRad (const Vector& v1, const Vector& v2)152 {153 return acos( v1 * v2 / (v1.len() * v2.len()));154 }155 156 157 /**158 \brief calculate the angle between two vectors in degrees159 \param v1: a vector160 \param v2: another vector161 \return the angle between the vectors in degrees162 */163 float angleDeg (const Vector& v1, const Vector& v2)164 {165 float f;166 f = acos( v1 * v2 / (v1.len() * v2.len()));167 return f * 180 / PI;168 }169 170 43 171 44 /**
Note: See TracChangeset
for help on using the changeset viewer.