Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4477 in orxonox.OLD for orxonox/trunk/src/lib/math/vector.cc


Ignore:
Timestamp:
Jun 2, 2005, 4:35:22 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: vector is completely documented again :)

File:
1 edited

Legend:

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

    r4476 r4477  
    2424using namespace std;
    2525
     26/////////////
     27/* VECTORS */
     28/////////////
    2629/**
    2730   \brief returns the this-vector normalized to length 1.0
     
    4346
    4447/**
     48   \brief Vector is looking in the positive direction on all axes after this
     49*/
     50Vector Vector::abs()
     51{
     52  Vector v(fabs(x), fabs(y), fabs(z));
     53  return v;
     54}
     55
     56
     57
     58/**
    4559   \brief Outputs the values of the Vector
    4660*/
     
    5367}
    5468
    55 /**
    56         \brief creates a multiplicational identity Quaternion
    57 */
    58 //Quaternion::Quaternion ()
    59 
    60 
    61 /**
    62         \brief turns a rotation along an axis into a Quaternion
    63         \param angle: the amount of radians to rotate
    64         \param axis: the axis to rotate around
    65 */
    66 //Quaternion::Quaternion (float angle, const Vector& axis)
    67 
    68 
     69/////////////////
     70/* QUATERNIONS */
     71/////////////////
    6972/**
    7073   \brief calculates a lookAt rotation
     
    109112
    110113/**
    111         \brief calculates a rotation from euler angles
    112         \param roll: the roll in radians
    113         \param pitch: the pitch in radians
    114         \param yaw: the yaw in radians
    115        
    116         I DO HONESTLY NOT EXACTLY KNOW WHICH ANGLE REPRESENTS WHICH ROTATION. And I do not know
    117         in what order they are applied, I just copy-pasted the code.
     114   \brief calculates a rotation from euler angles
     115   \param roll: the roll in radians
     116   \param pitch: the pitch in radians
     117   \param yaw: the yaw in radians
    118118*/
    119119Quaternion::Quaternion (float roll, float pitch, float yaw)
    120120{
    121         float cr, cp, cy, sr, sp, sy, cpcy, spsy;
    122        
    123         // calculate trig identities
    124         cr = cos(roll/2);
    125         cp = cos(pitch/2);
    126         cy = cos(yaw/2);
    127        
    128         sr = sin(roll/2);
    129         sp = sin(pitch/2);
    130         sy = sin(yaw/2);
    131        
    132         cpcy = cp * cy;
    133         spsy = sp * sy;
    134        
    135         w = cr * cpcy + sr * spsy;
    136         v.x = sr * cpcy - cr * spsy;
    137         v.y = cr * sp * cy + sr * cp * sy;
    138         v.z = cr * cp * sy - sr * sp * cy;
    139 }
    140 
    141 /**
    142         \brief rotates one Quaternion by another
    143         \param q: another Quaternion to rotate this by
    144         \return a quaternion that represents the first one rotated by the second one (WARUNING: this operation is not commutative! e.g. (A*B) != (B*A))
     121  float cr, cp, cy, sr, sp, sy, cpcy, spsy;
     122 
     123  // calculate trig identities
     124  cr = cos(roll/2);
     125  cp = cos(pitch/2);
     126  cy = cos(yaw/2);
     127 
     128  sr = sin(roll/2);
     129  sp = sin(pitch/2);
     130  sy = sin(yaw/2);
     131 
     132  cpcy = cp * cy;
     133  spsy = sp * sy;
     134 
     135  w = cr * cpcy + sr * spsy;
     136  v.x = sr * cpcy - cr * spsy;
     137  v.y = cr * sp * cy + sr * cp * sy;
     138  v.z = cr * cp * sy - sr * sp * cy;
     139}
     140
     141/**
     142   \brief rotates one Quaternion by another
     143   \param q: another Quaternion to rotate this by
     144   \return a quaternion that represents the first one rotated by the second one (WARUNING: this operation is not commutative! e.g. (A*B) != (B*A))
    145145*/
    146146Quaternion Quaternion::operator*(const Quaternion& q) const
     
    165165  return r;
    166166}
    167 
    168 /**
    169    \brief add two Quaternions
    170    \param q: another Quaternion
    171    \return the sum of both Quaternions
    172 */
    173 /*
    174 Quaternion Quaternion::operator+(const Quaternion& q) const
    175 {
    176   Quaternion r(*this);
    177   r.w = r.w + q.w;
    178   r.v = r.v + q.v;
    179   return r;
    180 }
    181 */
    182 
    183 /**
    184    \brief subtract two Quaternions
    185    \param q: another Quaternion
    186    \return the difference of both Quaternions
    187 */
    188 /*
    189 Quaternion Quaternion::operator- (const Quaternion& q) const
    190 {
    191   Quaternion r(*this);
    192   r.w = r.w - q.w;
    193   r.v = r.v - q.v;
    194   return r;
    195 }
    196 */
    197167
    198168/**
Note: See TracChangeset for help on using the changeset viewer.