1#pragma once
2
3#include <math/seadQuatCalcCommon.h>
4#ifndef SEAD_MATH_QUAT_H_
5#include <math/seadQuat.h>
6#endif
7
8namespace sead
9{
10template <typename T>
11inline Quat<T>::Quat(T w_, T x_, T y_, T z_)
12{
13 QuatCalcCommon<T>::set(*this, w_, x_, y_, z_);
14}
15
16template <typename T>
17inline Quat<T>& Quat<T>::operator*=(const Quat<T>& t)
18{
19 QuatCalcCommon<T>::setMul(*this, *this, t);
20 return *this;
21}
22
23template <typename T>
24inline T Quat<T>::length() const
25{
26 return QuatCalcCommon<T>::length(*this);
27}
28
29template <typename T>
30inline T Quat<T>::normalize()
31{
32 return QuatCalcCommon<T>::normalize(*this);
33}
34
35template <typename T>
36inline T Quat<T>::dot(const Self& q)
37{
38 return QuatCalcCommon<T>::dot(*this, q);
39}
40
41// reference?
42// conjugate(q) / dot(q)?
43template <typename T>
44inline void Quat<T>::inverse(Self* q)
45{
46 T prod = dot(q: *this);
47 if (prod > std::numeric_limits<T>::epsilon())
48 {
49 T inv = T(1) / prod;
50 q->w = inv * this->w;
51 q->x = inv * -this->x;
52 q->y = inv * -this->y;
53 q->z = inv * -this->z;
54 }
55 else
56 {
57 q->w = this->w;
58 q->x = -this->x;
59 q->y = -this->y;
60 q->z = -this->z;
61 }
62}
63
64template <typename T>
65inline void Quat<T>::makeUnit()
66{
67 QuatCalcCommon<T>::makeUnit(*this);
68}
69
70template <typename T>
71inline bool Quat<T>::makeVectorRotation(const Vec3& from, const Vec3& to)
72{
73 return QuatCalcCommon<T>::makeVectorRotation(*this, from, to);
74}
75
76template <typename T>
77inline void Quat<T>::set(const Self& other)
78{
79 QuatCalcCommon<T>::set(*this, other);
80}
81
82template <typename T>
83inline void Quat<T>::set(T w_, T x_, T y_, T z_)
84{
85 QuatCalcCommon<T>::set(*this, w_, x_, y_, z_);
86}
87
88template <typename T>
89inline void Quat<T>::setRPY(T roll, T pitch, T yaw)
90{
91 QuatCalcCommon<T>::setRPY(*this, roll, pitch, yaw);
92}
93
94template <typename T>
95inline void Quat<T>::calcRPY(Vec3& vec) const
96{
97 QuatCalcCommon<T>::calcRPY(vec, *this);
98}
99
100} // namespace sead
101