14 template<
typename Other,
15 int OtherRows=Other::RowsAtCompileTime,
16 int OtherCols=Other::ColsAtCompileTime>
46 template<
typename _Scalar>
54 using Base::operator*;
69 inline Scalar x()
const {
return m_coeffs.coeff(0); }
71 inline Scalar y()
const {
return m_coeffs.coeff(1); }
73 inline Scalar z()
const {
return m_coeffs.coeff(2); }
75 inline Scalar w()
const {
return m_coeffs.coeff(3); }
78 inline Scalar&
x() {
return m_coeffs.coeffRef(0); }
80 inline Scalar&
y() {
return m_coeffs.coeffRef(1); }
82 inline Scalar&
z() {
return m_coeffs.coeffRef(2); }
84 inline Scalar&
w() {
return m_coeffs.coeffRef(3); }
109 { m_coeffs << x,
y, z, w; }
122 template<
typename Derived>
127 template<
typename Derived>
167 template<
typename Derived1,
typename Derived2>
178 template<
typename Derived>
186 template<
typename NewScalarType>
191 template<
typename OtherScalarType>
193 { m_coeffs = other.
coeffs().template cast<Scalar>(); }
200 {
return m_coeffs.isApprox(other.
m_coeffs, prec); }
219 a.
w() * b.
w() - a.
x() * b.
x() - a.
y() * b.
y() - a.
z() * b.
z(),
220 a.
w() * b.
x() + a.
x() * b.
w() + a.
y() * b.
z() - a.
z() * b.
y(),
221 a.
w() * b.
y() + a.
y() * b.
w() + a.
z() * b.
x() - a.
x() * b.
z(),
222 a.
w() * b.
z() + a.
z() * b.
w() + a.
x() * b.
y() - a.
y() * b.
x()
227 template <
typename Scalar>
234 template <
typename Scalar>
237 return (*
this = *
this * other);
247 template <
typename Scalar>
248 template<
typename Derived>
258 uv = 2 * this->vec().
cross(v);
259 return v + this->w() * uv + this->vec().
cross(uv);
262 template<
typename Scalar>
271 template<
typename Scalar>
285 template<
typename Scalar>
286 template<
typename Derived>
294 template<
typename Scalar>
307 const Scalar twx = tx*this->w();
308 const Scalar twy = ty*this->w();
309 const Scalar twz = tz*this->w();
310 const Scalar txx = tx*this->x();
311 const Scalar txy = ty*this->x();
312 const Scalar txz = tz*this->x();
313 const Scalar tyy = ty*this->
y();
314 const Scalar tyz = tz*this->
y();
315 const Scalar tzz = tz*this->z();
336 template<
typename Scalar>
337 template<
typename Derived1,
typename Derived2>
342 Scalar c = v0.eigen2_dot(v1);
348 this->w() = 1; this->vec().
setZero();
354 this->vec() = v0.unitOrthogonal();
362 this->vec() = axis * invs;
363 this->w() = s *
Scalar(0.5);
374 template <
typename Scalar>
378 Scalar n2 = this->squaredNorm();
394 template <
typename Scalar>
397 return Quaternion(this->w(),-this->x(),-this->
y(),-this->z());
403 template <
typename Scalar>
406 double d =
ei_abs(this->eigen2_dot(other));
415 template <
typename Scalar>
418 static const Scalar one =
Scalar(1) - machine_epsilon<Scalar>();
419 Scalar d = this->eigen2_dot(other);
437 scale1 =
ei_sin( ( t * theta) ) / sinTheta;
446 template<
typename Other>
454 Scalar t = mat.trace();
458 q.
w() = Scalar(0.5)*t;
460 q.
x() = (mat.coeff(2,1) - mat.coeff(1,2)) * t;
461 q.
y() = (mat.coeff(0,2) - mat.coeff(2,0)) * t;
462 q.
z() = (mat.coeff(1,0) - mat.coeff(0,1)) * t;
467 if (mat.coeff(1,1) > mat.coeff(0,0))
469 if (mat.coeff(2,2) > mat.coeff(i,i))
474 t =
ei_sqrt(mat.coeff(i,i)-mat.coeff(j,j)-mat.coeff(k,k) + Scalar(1.0));
475 q.
coeffs().coeffRef(i) = Scalar(0.5) * t;
477 q.
w() = (mat.coeff(k,j)-mat.coeff(j,k))*t;
478 q.
coeffs().coeffRef(j) = (mat.coeff(j,i)+mat.coeff(i,j))*t;
479 q.
coeffs().coeffRef(k) = (mat.coeff(k,i)+mat.coeff(i,k))*t;
485 template<
typename Other>
Quaternion & setIdentity()
Quaternion(const Quaternion &other)
static void run(Quaternion< Scalar > &q, const Other &vec)
Matrix3 toRotationMatrix(void) const
static Matrix< Scalar, 2, 2 > toRotationMatrix(const Scalar &s)
static Quaternion Identity()
internal::cast_return_type< Quaternion, Quaternion< NewScalarType > >::type cast() const
Quaternion(Scalar w, Scalar x, Scalar y, Scalar z)
Quaternion operator*(const Quaternion &q) const
Scalar angularDistance(const Quaternion &other) const
iterative scaling algorithm to equilibrate rows and column norms in matrices
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
const internal::permut_matrix_product_retval< PermutationDerived, Derived, OnTheRight > operator*(const MatrixBase< Derived > &matrix, const PermutationBase< PermutationDerived > &permutation)
Block< Coefficients, 3, 1 > vec()
const Vector3 & axis() const
const CwiseUnaryOp< internal::scalar_inverse_op< Scalar >, const Derived > inverse() const
Quaternion(const MatrixBase< Derived > &other)
IntermediateState acos(const Expression &arg)
EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
const PlainObject normalized() const
Common base class for compact rotation representations.
Quaternion conjugate(void) const
ConjugateReturnType conjugate() const
bool ei_isApprox(const Scalar &x, const Scalar &y, typename NumTraits< Scalar >::Real precision=NumTraits< Scalar >::dummy_precision())
Quaternion & operator=(const Quaternion &other)
cross_product_return_type< OtherDerived >::type cross(const MatrixBase< OtherDerived > &other) const
NumTraits< T >::Real ei_abs(const T &x)
Expression of a fixed-size or dynamic-size block.
Quaternion normalized() const
The quaternion class used to represent 3D orientations and rotations.
Quaternion & operator*=(const Quaternion &q)
const Coefficients & coeffs() const
Quaternion(const AngleAxisType &aa)
Quaternion(const Quaternion< OtherScalarType > &other)
Scalar eigen2_dot(const Quaternion &other) const
Quaternion inverse(void) const
Quaternion< double > Quaterniond
static void run(Quaternion< Scalar > &q, const Other &mat)
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar, Size)
Scalar squaredNorm() const
The matrix class, also used for vectors and row-vectors.
Quaternion< float > Quaternionf
const Block< const Coefficients, 3, 1 > vec() const
Base class for all dense matrices, vectors, and expressions.
bool isApprox(const Quaternion &other, typename NumTraits< Scalar >::Real prec=precision< Scalar >()) const
Represents a 3D rotation as a rotation angle around an arbitrary 3D axis.
RotationBase< Quaternion< _Scalar >, 3 > Base
Quaternion< Scalar > ei_quaternion_product(const Quaternion< Scalar > &a, const Quaternion< Scalar > &b)
Quaternion slerp(Scalar t, const Quaternion &other) const
Quaternion & setFromTwoVectors(const MatrixBase< Derived1 > &a, const MatrixBase< Derived2 > &b)