11#pragma once
22
3+
4+ #include < cassert>
5+
6+
37namespace ad {
48namespace math {
59
@@ -103,15 +107,15 @@ constexpr T_number Quaternion<T_number>::w() const noexcept(should_noexcept)
103107
104108
105109template <class T_number >
106- constexpr Quaternion<T_number> Quaternion<T_number>::operator -()
110+ constexpr Quaternion<T_number> Quaternion<T_number>::operator -()
107111const noexcept (should_noexcept)
108112{
109113 return {-mVector , -mW };
110114}
111115
112116
113117template <class T_number >
114- constexpr Quaternion<T_number> & Quaternion<T_number>::operator *=(const Quaternion & aRhs)
118+ constexpr Quaternion<T_number> & Quaternion<T_number>::operator *=(const Quaternion & aRhs)
115119noexcept (should_noexcept)
116120{
117121 T_number w = mW * aRhs.mW - mVector .dot (aRhs.mVector );
@@ -132,12 +136,12 @@ template <class T_number>
132136constexpr Quaternion<T_number> Quaternion<T_number>::inverse() const noexcept (should_noexcept)
133137{
134138 // IMPORTANT This is true only because we expect Quaternion to be a unit quaternion.
135- return conjugate ();
139+ return conjugate ();
136140}
137141
138142
139143template <class T_number >
140- template <class T_derived >
144+ template <class T_derived >
141145// requires (is_position_v<T_derived> || is_vec_v<T_derived>)
142146T_derived Quaternion<T_number>::rotate(const Vector<T_derived, 3 , T_number> & aVector) const
143147noexcept (should_noexcept)
@@ -148,7 +152,7 @@ noexcept(should_noexcept)
148152
149153
150154template <class T_number >
151- constexpr LinearMatrix<3 , 3 , T_number> Quaternion<T_number>::toRotationMatrix() const
155+ constexpr LinearMatrix<3 , 3 , T_number> Quaternion<T_number>::toRotationMatrix() const
152156noexcept (should_noexcept)
153157{
154158 return {
@@ -161,17 +165,17 @@ noexcept(should_noexcept)
161165
162166
163167template <class T_number >
164- constexpr bool
168+ constexpr bool
165169Quaternion<T_number>::equalsWithinTolerance(const Quaternion & aRhs, T_number aEpsilon) const
166170noexcept (should_noexcept)
167171{
168- return mVector .equalsWithinTolerance (aRhs.mVector , aEpsilon)
172+ return mVector .equalsWithinTolerance (aRhs.mVector , aEpsilon)
169173 && std::abs (mW - aRhs.mW ) <= aEpsilon;
170174}
171175
172176
173177template <class T_number >
174- constexpr Vec<4 , T_number> Quaternion<T_number>::asVec() const
178+ constexpr Vec<4 , T_number> Quaternion<T_number>::asVec() const
175179noexcept (should_noexcept)
176180{
177181 return {mVector , mW };
@@ -183,7 +187,7 @@ noexcept(should_noexcept)
183187//
184188template <class T_number >
185189constexpr Quaternion<T_number>
186- operator *(Quaternion<T_number> aLhs, const Quaternion<T_number> & aRhs)
190+ operator *(Quaternion<T_number> aLhs, const Quaternion<T_number> & aRhs)
187191noexcept (decltype (aLhs)::should_noexcept)
188192{
189193 return aLhs *= aRhs;
@@ -192,7 +196,7 @@ noexcept(decltype(aLhs)::should_noexcept)
192196
193197template <class T_number >
194198constexpr Quaternion<T_number>
195- difference (Quaternion<T_number> aLhs, const Quaternion<T_number> & aRhs)
199+ difference (Quaternion<T_number> aLhs, const Quaternion<T_number> & aRhs)
196200noexcept (decltype (aLhs)::should_noexcept)
197201{
198202 return aRhs * aLhs.inverse ();
@@ -210,10 +214,10 @@ noexcept(decltype(aLhs)::should_noexcept)
210214template <class T_number >
211215std::ostream & operator <<(std::ostream & aOut, const Quaternion<T_number> & aQuaternion)
212216{
213- return aOut << " <q>{"
217+ return aOut << " <q>{"
214218 << aQuaternion.x () << " , "
215219 << aQuaternion.y () << " , "
216- << aQuaternion.z () << " , "
220+ << aQuaternion.z () << " , "
217221 << aQuaternion.w ()
218222 << " }"
219223 ;
@@ -231,7 +235,7 @@ Quaternion<T_number> toQuaternion(const LinearMatrix<3, 3, T_number> & m)
231235 m.at (2 , 2 ) - m.at (0 , 0 ) - m.at (1 , 1 ),
232236 }};
233237
234- auto maxElementIt =
238+ auto maxElementIt =
235239 std::max_element (std::begin (fourTimesSquaredMinusOne),
236240 std::end (fourTimesSquaredMinusOne));
237241
0 commit comments