29 : w(w), x(x), y(y), z(z) {
49 return !(*
this == other);
61 template <
typename OT>
71 template <
typename OT>
92 T lengthSquared()
const {
93 return w*w + x*x + y*y + z*z;
96 template <
typename Tout = decltype(std::sqrt(T(0)))>
98 return static_cast<Tout
>(std::sqrt(lengthSquared()));
102 auto lensq = lengthSquared();
104 *
this /= std::sqrt(lensq);
114 template <
typename OT>
116 return *
this =
Quaternion<T>(this->w*q.w - this->x*q.x - this->y*q.y - this->z*q.z,
117 this->w*q.x + this->x*q.w + this->y*q.z - this->z*q.y,
118 this->w*q.y - this->x*q.z + this->y*q.w + this->z*q.x,
119 this->w*q.z + this->x*q.y - this->y*q.x + this->z*q.w);
124 auto lensq = lengthSquared();
126 (*this).conjugate() /= lensq;
153 template <
typename T1,
typename T2>
160 template <
typename T1,
typename T2>
161 auto operator-(
const Quaternion<T1>& q1,
const Quaternion<T2>& q2)
162 -> Quaternion<decltype(T1(0) - T2(0))> {
166 template <
typename T,
typename S>
167 auto operator*(
const Quaternion<T>& q, S s)
168 -> Quaternion<decltype(T(0) * S(0))> {
169 Quaternion<decltype(T(0) * S(0))> out(q);
173 template <
typename T,
typename S>
174 auto operator*(S s,
const Quaternion<T>& q)
175 -> Quaternion<decltype(T(0) * S(0))> {
179 template <
typename T,
typename S>
180 auto operator/(
const Quaternion<T>& q, S s)
181 -> Quaternion<decltype(T(0) / S(0))> {
185 template <
typename T,
typename S>
186 auto operator/(S s,
const Quaternion<T>& q)
187 -> Quaternion<decltype(T(0) / S(0))> {
188 return s * q.inverse();
Represents the hamilton ring H(T) for an arbitrary type T.
Definition: QuaternionCore.hpp:25