2
* $Id: MT_Quaternion.h,v 1.6 2002/12/26 18:25:15 mein Exp $
2
* $Id: MT_Quaternion.h,v 1.8 2005/03/25 14:48:29 sirdude Exp $
3
3
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
5
* This program is free software; you can redistribute it and/or
59
59
MT_Quaternion(const double v[4]) : MT_Vector4(v) {}
60
60
MT_Quaternion(MT_Scalar xx, MT_Scalar yy, MT_Scalar zz, MT_Scalar ww) :
61
61
MT_Vector4(xx, yy, zz, ww) {}
62
MT_Quaternion(const MT_Vector3& axis, MT_Scalar angle) {
63
setRotation(axis, angle);
62
MT_Quaternion(const MT_Vector3& axis, MT_Scalar mt_angle) {
63
setRotation(axis, mt_angle);
65
65
MT_Quaternion(MT_Scalar yaw, MT_Scalar pitch, MT_Scalar roll) {
66
66
setEuler(yaw, pitch, roll);
69
void setRotation(const MT_Vector3& axis, MT_Scalar angle) {
69
void setRotation(const MT_Vector3& axis, MT_Scalar mt_angle) {
70
70
MT_Scalar d = axis.length();
71
71
MT_assert(!MT_fuzzyZero(d));
72
MT_Scalar s = sin(angle * MT_Scalar(0.5)) / d;
72
MT_Scalar s = sin(mt_angle * MT_Scalar(0.5)) / d;
73
73
setValue(axis[0] * s, axis[1] * s, axis[2] * s,
74
cos(angle * MT_Scalar(0.5)));
74
cos(mt_angle * MT_Scalar(0.5)));
77
77
void setEuler(MT_Scalar yaw, MT_Scalar pitch, MT_Scalar roll) {
96
96
MT_Quaternion inverse() const;
98
MT_Scalar angle(const MT_Quaternion& q) const;
99
MT_Quaternion slerp(const MT_Quaternion& q, const MT_Scalar& t) const;
98
101
static MT_Quaternion random();