73 WWINLINE void Set(
float a = 0.0,
float b = 0.0,
float c = 0.0,
float d = 1.0) {
X = a;
Y = b;
Z = c;
W = d; }
131 return Quaternion(a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3]);
137 return Quaternion(a[0] - b[0], a[1] - b[1], a[2] - b[2], a[3] - b[3]);
143 return Quaternion(scl*a[0], scl*a[1], scl*a[2], scl*a[3]);
157 a.
W*b.
X + b.
W*a.
X + (a.
Y*b.
Z - b.
Y*a.
Z),
158 a.
W*b.
Y + b.
W*a.
Y - (a.
X*b.
Z - b.
X*a.
Z),
159 a.
W*b.
Z + b.
W*a.
Z + (a.
X*b.
Y - b.
X*a.
Y),
160 a.
W * b.
W - (a.
X * b.
X + a.
Y * b.
Y + a.
Z * b.
Z)
177 float oomag = 1.0f / mag;
178 return Quaternion(a[0] * oomag, a[1] * oomag, a[2] * oomag, a[3] * oomag);
210 out[0][0] = (float)(1.0 - 2.0 * (
q[1] *
q[1] +
q[2] *
q[2]));
211 out[0][1] = (float)(2.0 * (
q[0] *
q[1] -
q[2] *
q[3]));
212 out[0][2] = (float)(2.0 * (
q[2] *
q[0] +
q[1] *
q[3]));
214 out[1][0] = (float)(2.0 * (
q[0] *
q[1] +
q[2] *
q[3]));
215 out[1][1] = (float)(1.0 - 2.0f * (
q[2] *
q[2] +
q[0] *
q[0]));
216 out[1][2] = (float)(2.0 * (
q[1] *
q[2] -
q[0] *
q[3]));
218 out[2][0] = (float)(2.0 * (
q[2] *
q[0] -
q[1] *
q[3]));
219 out[2][1] = (float)(2.0 * (
q[1] *
q[2] +
q[0] *
q[3]));
220 out[2][2] =(float)(1.0 - 2.0 * (
q[1] *
q[1] +
q[0] *
q[0]));
223 out[0][3] = out[1][3] = out[2][3] = 0.0f;
248 float x =
W*v.
X + (
Y*v.
Z - v.
Y*
Z);
249 float y =
W*v.
Y - (
X*v.
Z - v.
X*
Z);
250 float z =
W*v.
Z + (
X*v.
Y - v.
X*
Y);
251 float w = -(
X*v.
X +
Y*v.
Y +
Z*v.
Z);
255 w*(-
X) +
W*x + (y*(-
Z) - (-
Y)*z),
256 w*(-
Y) +
W*y - (x*(-
Z) - (-
X)*z),
257 w*(-
Z) +
W*z + (x*(-
Y) - (-
X)*y)
263 assert(result !=
NULL);
265 float x =
W*v.
X + (
Y*v.
Z - v.
Y*
Z);
266 float y =
W*v.
Y - (
X*v.
Z - v.
X*
Z);
267 float z =
W*v.
Z + (
X*v.
Y - v.
X*
Y);
268 float w = -(
X*v.
X +
Y*v.
Y +
Z*v.
Z);
270 result->
X = w*(-
X) +
W*x + (y*(-
Z) - (-
Y)*z);
271 result->
Y = w*(-
Y) +
W*y - (x*(-
Z) - (-
X)*z);
272 result->
Z = w*(-
Z) +
W*z + (x*(-
Y) - (-
X)*y);
WWINLINE Quaternion(float a, float b, float c, float d)
WWINLINE Quaternion(void)
void Rotate_Y(float theta)
Quaternion & Make_Closest(const Quaternion &qto)
WWINLINE void Make_Identity(void)
WWINLINE Vector3 Rotate_Vector(const Vector3 &v) const
WWINLINE Quaternion(bool init)
WWINLINE Quaternion operator+() const
WWINLINE float Length(void) const
WWINLINE Quaternion & operator=(const Quaternion &source)
WWINLINE void Scale(float s)
void Rotate_X(float theta)
WWINLINE float Length2(void) const
WWINLINE Quaternion operator-() const
void Rotate_Z(float theta)
WWINLINE float & operator[](int i)
bool Is_Valid(void) const
WWINLINE void Set(float a=0.0, float b=0.0, float c=0.0, float d=1.0)
static float Sqrt(float val)
static bool Is_Valid_Float(float x)
static WWINLINE float Fabs(float val)
void Slerp_Setup(const Quaternion &p, const Quaternion &q, SlerpInfoStruct *slerpinfo)
Matrix4x4 Build_Matrix4(const Quaternion &quat)
void __cdecl Slerp(Quaternion &result, const Quaternion &a, const Quaternion &b, float t)
Quaternion Axis_To_Quat(const Vector3 &a, float angle)
WWINLINE Quaternion operator-(const Quaternion &a, const Quaternion &b)
WWINLINE bool Equal_Within_Epsilon(const Quaternion &a, const Quaternion &b, float epsilon)
void Cached_Slerp(const Quaternion &p, const Quaternion &q, float alpha, SlerpInfoStruct *slerpinfo, Quaternion *set_q)
WWINLINE Quaternion operator+(const Quaternion &a, const Quaternion &b)
Quaternion Trackball(float x0, float y0, float x1, float y1, float sphsize)
WWINLINE Quaternion Inverse(const Quaternion &a)
WWINLINE Quaternion Conjugate(const Quaternion &a)
Quaternion Build_Quaternion(const Matrix3x3 &matrix)
Matrix3D & Build_Matrix3D(const Quaternion &q, Matrix3D &out)
WWINLINE Quaternion operator*(float scl, const Quaternion &a)
Matrix3x3 Build_Matrix3(const Quaternion &quat)
WWINLINE Quaternion Normalize(const Quaternion &a)
void __cdecl Fast_Slerp(Quaternion &result, const Quaternion &a, const Quaternion &b, float t)
WWINLINE Quaternion operator/(const Quaternion &a, const Quaternion &b)