Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jul 4, 2006, 11:18:41 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the Presentation back

Location:
trunk/src/lib/math
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/math/curve.cc

    r5232 r9110  
    2929#include "debug.h"
    3030
    31 #include <math.h>
     31#include <cmath>
    3232#include <stdio.h>
    3333
  • trunk/src/lib/math/line.h

    r6617 r9110  
    2424#define __LINE_H_
    2525
    26 #include <math.h>
    2726#include "compiler.h"
    2827#include "vector.h"
  • trunk/src/lib/math/matrix.cc

    r7711 r9110  
    1414*/
    1515#include "matrix.h"
    16 #include <math.h>
     16#include <cmath>
    1717
    1818#ifdef DEBUG
  • trunk/src/lib/math/matrix.h

    r5698 r9110  
    44 */
    55
    6 #include <math.h>
    76#include "vector.h"
    87
  • trunk/src/lib/math/plane.h

    r7711 r9110  
    2424#define __PLANE_H_
    2525
    26 #include <math.h>
    2726#include "compiler.h"
    2827#include "vector.h"
  • trunk/src/lib/math/quaternion.cc

    r8731 r9110  
    2828  #define PRINT(x) printf
    2929#endif
    30 
    31 using namespace std;
    3230
    3331/////////////////
     
    5856  m[0][1] = x.y;
    5957  m[0][2] = x.z;
    60   m[0][3] = 0;
     58  m[0][3] = 0.0;
    6159  m[1][0] = y.x;
    6260  m[1][1] = y.y;
    6361  m[1][2] = y.z;
    64   m[1][3] = 0;
     62  m[1][3] = 0.0;
    6563  m[2][0] = z.x;
    6664  m[2][1] = z.y;
    6765  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);
    7573}
    7674
     
    279277 * @param m: a 4x4 matrix in glMatrix order
    280278 */
    281 Quaternion::Quaternion (float m[4][4])
     279void Quaternion::from4x4(float m[4][4])
    282280{
    283281
     
    285283  int    i, j, k;
    286284
    287   int nxt[3] = {1, 2, 0};
     285  static int nxt[3] = {1, 2, 0};
    288286
    289287  tr = m[0][0] + m[1][1] + m[2][2];
     
    327325
    328326/**
    329  * Creates a quaternion from a 3x3 rotation matrix.
     327 * applies a quaternion from a 3x3 rotation matrix.
    330328 * @param mat The 3x3 source rotation matrix.
    331329 * @return The equivalent 4 float quaternion.
    332330 */
    333 Quaternion::Quaternion(float mat[3][3])
     331void Quaternion::from3x3(float mat[3][3])
    334332{
    335333  int   NXT[] = {1, 2, 0};
  • trunk/src/lib/math/quaternion.h

    r8894 r9110  
    2424#define __QUATERNION_H_
    2525
    26 #include <math.h>
    2726#include "compiler.h"
    28 //! PI the circle-constant
    29 #define PI 3.14159265359f
    3027#include "vector.h"
    3128
     
    3936  /** creates a Default quaternion (multiplicational identity Quaternion)*/
    4037  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; };
    4140  /** creates a Quaternion looking into the direction v @param v: the direction @param f: the value */
    4241  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]);
    4542  /** turns a rotation along an axis into a Quaternion @param angle: the amount of radians to rotate @param axis: the axis to rotate around */
    4643  inline Quaternion (float angle, const Vector& axis) { w = cos(angle/2.0); v = axis * sin(angle/2.0); }
    4744  Quaternion (const Vector& dir, const Vector& up);
    4845  Quaternion (float roll, float pitch, float yaw);
     46
     47  void from3x3(float m[3][3]);
     48  void from4x4(float m[4][4]);
     49
    4950
    5051  /** @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  
    2929#endif
    3030
    31 using namespace std;
    3231
    3332/////////////
     
    4039Vector Vector::getNormalized() const
    4140{
    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))
    4443    return *this;
    4544  else
    46     return (*this / l);
     45    return (*this / length);
    4746}
    4847
  • trunk/src/lib/math/vector.h

    r8894 r9110  
    2424#define __VECTOR_H_
    2525
    26 #include <math.h>
     26#include <cmath>
    2727#include "compiler.h"
    2828//! PI the circle-constant
     
    4242  Vector (float x, float y, float z) : x(x), y(y), z(z) {}  //!< assignment constructor
    4343  Vector () : x(0), y(0), z(0) {}
    44   ~Vector () {}
    4544
    4645  /** @param v: the Vecor to compare with this one @returns true, if the Vecors are the same, false otherwise */
     
    9089  void scale(const Vector& v) {   x *= v.x;  y *= v.y; z *= v.z; };
    9190  /** @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); }
    9392  /** normalizes the vector */
    9493  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.