Changeset 9110 in orxonox.OLD for trunk/src/lib/math
- Timestamp:
- Jul 4, 2006, 11:18:41 AM (18 years ago)
- Location:
- trunk/src/lib/math
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/math/curve.cc
r5232 r9110 29 29 #include "debug.h" 30 30 31 #include < math.h>31 #include <cmath> 32 32 #include <stdio.h> 33 33 -
trunk/src/lib/math/line.h
r6617 r9110 24 24 #define __LINE_H_ 25 25 26 #include <math.h>27 26 #include "compiler.h" 28 27 #include "vector.h" -
trunk/src/lib/math/matrix.cc
r7711 r9110 14 14 */ 15 15 #include "matrix.h" 16 #include < math.h>16 #include <cmath> 17 17 18 18 #ifdef DEBUG -
trunk/src/lib/math/matrix.h
r5698 r9110 4 4 */ 5 5 6 #include <math.h>7 6 #include "vector.h" 8 7 -
trunk/src/lib/math/plane.h
r7711 r9110 24 24 #define __PLANE_H_ 25 25 26 #include <math.h>27 26 #include "compiler.h" 28 27 #include "vector.h" -
trunk/src/lib/math/quaternion.cc
r8731 r9110 28 28 #define PRINT(x) printf 29 29 #endif 30 31 using namespace std;32 30 33 31 ///////////////// … … 58 56 m[0][1] = x.y; 59 57 m[0][2] = x.z; 60 m[0][3] = 0 ;58 m[0][3] = 0.0; 61 59 m[1][0] = y.x; 62 60 m[1][1] = y.y; 63 61 m[1][2] = y.z; 64 m[1][3] = 0 ;62 m[1][3] = 0.0; 65 63 m[2][0] = z.x; 66 64 m[2][1] = z.y; 67 65 m[2][2] = z.z; 68 m[2][3] = 0 ;69 m[3][0] = 0 ;70 m[3][1] = 0 ;71 m[3][2] = 0 ;72 m[3][3] = 1 ;73 74 *this = Quaternion(m);66 m[2][3] = 0.0; 67 m[3][0] = 0.0; 68 m[3][1] = 0.0; 69 m[3][2] = 0.0; 70 m[3][3] = 1.0; 71 72 this->from4x4(m); 75 73 } 76 74 … … 279 277 * @param m: a 4x4 matrix in glMatrix order 280 278 */ 281 Quaternion::Quaternion(float m[4][4])279 void Quaternion::from4x4(float m[4][4]) 282 280 { 283 281 … … 285 283 int i, j, k; 286 284 287 int nxt[3] = {1, 2, 0};285 static int nxt[3] = {1, 2, 0}; 288 286 289 287 tr = m[0][0] + m[1][1] + m[2][2]; … … 327 325 328 326 /** 329 * Creates a quaternion from a 3x3 rotation matrix.327 * applies a quaternion from a 3x3 rotation matrix. 330 328 * @param mat The 3x3 source rotation matrix. 331 329 * @return The equivalent 4 float quaternion. 332 330 */ 333 Quaternion::Quaternion(float mat[3][3])331 void Quaternion::from3x3(float mat[3][3]) 334 332 { 335 333 int NXT[] = {1, 2, 0}; -
trunk/src/lib/math/quaternion.h
r8894 r9110 24 24 #define __QUATERNION_H_ 25 25 26 #include <math.h>27 26 #include "compiler.h" 28 //! PI the circle-constant29 #define PI 3.14159265359f30 27 #include "vector.h" 31 28 … … 39 36 /** creates a Default quaternion (multiplicational identity Quaternion)*/ 40 37 inline Quaternion () { w = 1; v = Vector(0,0,0); } 38 /** Copy constructor @param q the Quaternion to copy. */ 39 inline Quaternion (const Quaternion& q) { w = q.w; v = q.v; }; 41 40 /** creates a Quaternion looking into the direction v @param v: the direction @param f: the value */ 42 41 inline Quaternion (const Vector& v, float f) { this->w = f; this->v = v; } 43 Quaternion (float m[4][4]);44 Quaternion (float m[3][3]);45 42 /** turns a rotation along an axis into a Quaternion @param angle: the amount of radians to rotate @param axis: the axis to rotate around */ 46 43 inline Quaternion (float angle, const Vector& axis) { w = cos(angle/2.0); v = axis * sin(angle/2.0); } 47 44 Quaternion (const Vector& dir, const Vector& up); 48 45 Quaternion (float roll, float pitch, float yaw); 46 47 void from3x3(float m[3][3]); 48 void from4x4(float m[4][4]); 49 49 50 50 51 /** @param q: the Quaternion to compare with this one. @returns true if the Quaternions are the same, false otherwise */ -
trunk/src/lib/math/vector.cc
r6617 r9110 29 29 #endif 30 30 31 using namespace std;32 31 33 32 ///////////// … … 40 39 Vector Vector::getNormalized() const 41 40 { 42 float l = this->len();43 if (unlikely(l == 1.0 || l== 0.0))41 float length = this->len(); 42 if (unlikely(length == 0.0)) 44 43 return *this; 45 44 else 46 return (*this / l );45 return (*this / length); 47 46 } 48 47 -
trunk/src/lib/math/vector.h
r8894 r9110 24 24 #define __VECTOR_H_ 25 25 26 #include < math.h>26 #include <cmath> 27 27 #include "compiler.h" 28 28 //! PI the circle-constant … … 42 42 Vector (float x, float y, float z) : x(x), y(y), z(z) {} //!< assignment constructor 43 43 Vector () : x(0), y(0), z(0) {} 44 ~Vector () {}45 44 46 45 /** @param v: the Vecor to compare with this one @returns true, if the Vecors are the same, false otherwise */ … … 90 89 void scale(const Vector& v) { x *= v.x; y *= v.y; z *= v.z; }; 91 90 /** @returns the length of the vector */ 92 inline float len() const { return sqrt (x*x +y*y+z*z); }91 inline float len() const { return sqrt (x*x + y*y + z*z); } 93 92 /** normalizes the vector */ 94 93 inline void normalize() { float l = len(); if( unlikely(l == 0.0))return; this->x=this->x/l; this->y=this->y/l; this->z=this->z/l; };
Note: See TracChangeset
for help on using the changeset viewer.