@@ -158,6 +158,27 @@ struct TransformT {
158158 return toRotationMatrix () * scale;
159159 }
160160
161+ // / Gets the X axis of the rotation
162+ [[nodiscard]] Vector3<T> getAxisX () const {
163+ // Optimized version of Eigen::Quaternion::toRotationMatrix()
164+ Vector3<T> axis;
165+
166+ const T ty = T (2 ) * rotation.y ();
167+ const T tz = T (2 ) * rotation.z ();
168+ const T twy = ty * rotation.w ();
169+ const T twz = tz * rotation.w ();
170+ const T txy = ty * rotation.x ();
171+ const T txz = tz * rotation.x ();
172+ const T tyy = ty * rotation.y ();
173+ const T tzz = tz * rotation.z ();
174+
175+ axis[0 ] = T (1 ) - (tyy + tzz);
176+ axis[1 ] = txy + twz;
177+ axis[2 ] = txz - twy;
178+
179+ return axis;
180+ }
181+
161182 // / Applies full transform to a point
162183 [[nodiscard]] Vector3<T> transformPoint (const Vector3<T>& pt) const {
163184 return translation + rotation * (scale * pt).eval ();
@@ -179,6 +200,14 @@ struct TransformT {
179200 this ->rotation .template cast <T2>(),
180201 static_cast <T2>(this ->scale ));
181202 }
203+
204+ // / Checks if this transform is approximately equal to another
205+ [[nodiscard]] bool isApprox (
206+ const TransformT<T>& other,
207+ T tol = Eigen::NumTraits<T>::dummy_precision()) const {
208+ // TODO: Improve
209+ return toAffine3 ().isApprox (other.toAffine3 (), tol);
210+ }
182211};
183212
184213template <typename T>
0 commit comments