Changeset 7191 in orxonox.OLD for trunk/src/lib/math/quaternion.cc
- Timestamp:
- Mar 1, 2006, 10:30:06 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/math/quaternion.cc
r7003 r7191 131 131 m[2][3] = 0; m[3][3] = 1; 132 132 } 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 */ 140 void 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 133 174 134 175 /**
Note: See TracChangeset
for help on using the changeset viewer.