Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7191 in orxonox.OLD


Ignore:
Timestamp:
Mar 1, 2006, 10:30:06 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: some better and faster slerp functions

Location:
trunk/src
Files:
4 edited

Legend:

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

    r7003 r7191  
    131131  m[2][3] = 0; m[3][3] = 1;
    132132}
     133
     134
     135/**
     136 * Slerps this QUaternion performs a smooth move.
     137 * @param toQuat to this Quaternion
     138 * @param t \% inth the the direction[0..1]
     139 */
     140void Quaternion::slerpTo(const Quaternion& toQuat, float t)
     141{
     142  float tol[4];
     143  double omega, cosom, sinom, scale0, scale1;
     144  //  float DELTA = 0.2;
     145
     146  cosom = this->v.x * toQuat.v.x + this->v.y * toQuat.v.y + this->v.z * toQuat.v.z + this->w * toQuat.w;
     147
     148  if( cosom < 0.0 )
     149  {
     150    cosom = -cosom;
     151    tol[0] = -toQuat.v.x;
     152    tol[1] = -toQuat.v.y;
     153    tol[2] = -toQuat.v.z;
     154    tol[3] = -toQuat.w;
     155  }
     156  else
     157  {
     158    tol[0] = toQuat.v.x;
     159    tol[1] = toQuat.v.y;
     160    tol[2] = toQuat.v.z;
     161    tol[3] = toQuat.w;
     162  }
     163
     164  omega = acos(cosom);
     165  sinom = sin(omega);
     166  scale0 = sin((1.0 - t) * omega) / sinom;
     167  scale1 = sin(t * omega) / sinom;
     168  this->v = Vector(scale0 * this->v.x + scale1 * tol[0],
     169                    scale0 * this->v.y + scale1 * tol[1],
     170                    scale0 * this->v.z + scale1 * tol[2]);
     171  this->w = scale0 * this->w + scale1 * tol[3];
     172}
     173
    133174
    134175/**
  • trunk/src/lib/math/quaternion.h

    r7003 r7191  
    101101  inline float getSpacialAxisAngle() const { return 360.0 / M_PI * acos( this->w ); };
    102102
     103
     104  inline void slerpTo(const Quaternion& toQuat, float t);
    103105  static Quaternion quatSlerp(const Quaternion& from, const Quaternion& to, float t);
    104106
  • trunk/src/lib/math/vector.h

    r6617 r7191  
    9797  Vector getNormalized() const;
    9898  Vector abs();
     99  /** @param toVec nears this Vector to... @param t how much to advance (0.0: not at all; 1.0: fully) */
     100  inline void slerpTo(const Vector& toVec, float t) { *this + (toVec - *this) * t; };
    99101
    100102  void debug() const;
  • trunk/src/subprojects/collision_detection/Makefile.am

    r7156 r7191  
    55include $(MAINSRCDIR)/lib/BuildLibs.am
    66
    7 
    8 importer_LDFLAGS = \
    9                 $(MWINDOWS)
    107
    118bin_PROGRAMS = collision
     
    2421                $(GTK2_LIBS) $(GTHREAD_LIBS) $(CURL_LIBS)
    2522
    26 importer_SOURCES= \
    27                 ../framework.cc \
    28                 importer.cc \
    29                 $(MAINSRCDIR)/world_entities/space_ships/space_ship.cc \
    30                 $(MAINSRCDIR)/world_entities/weapons/test_gun.cc
    31 
    32 
    3323
    3424collision_CPPFLAGS =  \
Note: See TracChangeset for help on using the changeset viewer.