Changeset 9639 in orxonox.OLD for branches/proxy/src/lib/math/quaternion.cc
- Timestamp:
- Jul 31, 2006, 9:30:52 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/proxy/src/lib/math/quaternion.cc
r9110 r9639 336 336 // check the diagonal 337 337 float tr = mat[0][0] + mat[1][1] + mat[2][2]; 338 if( tr > 0.0f) { 338 if( tr > 0.0f) 339 { 339 340 float s = (float)sqrtf(tr + 1.0f); 340 341 this->w = s * 0.5f; … … 372 373 } 373 374 375 Quaternion Quaternion::lookAt(Vector from, Vector to, Vector up) 376 { 377 Vector n = to - from; 378 n.normalize(); 379 Vector v = n.cross(up); 380 v.normalize(); 381 Vector u = v.cross(n); 382 383 float matrix[3][3]; 384 matrix[0][0] = v.x; 385 matrix[0][1] = v.y; 386 matrix[0][2] = v.z; 387 matrix[1][0] = u.x; 388 matrix[1][1] = u.y; 389 matrix[1][2] = u.z; 390 matrix[2][0] = -n.x; 391 matrix[2][1] = -n.y; 392 matrix[2][2] = -n.z; 393 394 Quaternion quat; 395 quat.from3x3(matrix); 396 return quat; 397 } 398 399 374 400 /** 375 401 * @brief outputs some nice formated debug information about this quaternion
Note: See TracChangeset
for help on using the changeset viewer.