11 #ifndef EIGEN_QUATERNION_H 12 #define EIGEN_QUATERNION_H 22 template<
typename Other,
23 int OtherRows=Other::RowsAtCompileTime,
24 int OtherCols=Other::ColsAtCompileTime>
34 template<
class Derived>
40 using Base::operator*;
147 template<
typename Derived1,
typename Derived2>
165 template<
class OtherDerived>
167 {
return coeffs() == other.
coeffs(); }
173 template<
class OtherDerived>
175 {
return coeffs() != other.
coeffs(); }
181 template<
class OtherDerived>
183 {
return coeffs().isApprox(other.
coeffs(), prec); }
188 #ifdef EIGEN_PARSED_BY_DOXYGEN 194 template<
typename NewScalarType>
199 template<
typename NewScalarType>
206 template<
typename NewScalarType>
215 friend std::ostream& operator<<(std::ostream& s, const QuaternionBase<Derived>&
q) {
216 s << q.
x() <<
"i + " << q.
y() <<
"j + " << q.
z() <<
"k" <<
" + " << q.
w();
221 #ifdef EIGEN_QUATERNIONBASE_PLUGIN 222 # include EIGEN_QUATERNIONBASE_PLUGIN 259 template<
typename _Scalar,
int _Options>
272 template<
typename _Scalar,
int _Options>
282 using Base::operator*=;
312 template<
typename Derived>
316 template<
typename OtherScalar,
int OtherOptions>
318 { m_coeffs = other.
coeffs().template cast<Scalar>(); }
320 #if EIGEN_HAS_RVALUE_REFERENCES 324 : m_coeffs(std::move(other.
coeffs()))
330 m_coeffs = std::move(other.
coeffs());
337 template<
typename Derived1,
typename Derived2>
345 #ifdef EIGEN_QUATERNION_PLUGIN 346 # include EIGEN_QUATERNION_PLUGIN 352 #ifndef EIGEN_PARSED_BY_DOXYGEN 356 INVALID_MATRIX_TEMPLATE_PARAMETERS)
373 template<
typename _Scalar,
int _Options>
374 struct traits<
Map<
Quaternion<_Scalar>, _Options> > :
traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> >
381 template<
typename _Scalar,
int _Options>
382 struct traits<
Map<const
Quaternion<_Scalar>, _Options> > :
traits<Quaternion<_Scalar, (int(_Options)&Aligned)==Aligned ? AutoAlign : DontAlign> >
403 template<
typename _Scalar,
int _Options>
405 :
public QuaternionBase<Map<const Quaternion<_Scalar>, _Options> >
413 using Base::operator*=;
440 template<
typename _Scalar,
int _Options>
450 using Base::operator*=;
487 template<
int Arch,
class Derived1,
class Derived2,
typename Scalar>
struct quat_product 492 a.
w() * b.
w() - a.
x() * b.
x() - a.
y() * b.
y() - a.
z() * b.
z(),
493 a.
w() * b.
x() + a.
x() * b.
w() + a.
y() * b.
z() - a.
z() * b.
y(),
494 a.
w() * b.
y() + a.
y() * b.
w() + a.
z() * b.
x() - a.
x() * b.
z(),
495 a.
w() * b.
z() + a.
z() * b.
w() + a.
x() * b.
y() - a.
y() * b.
x()
502 template <
class Derived>
503 template <
class OtherDerived>
508 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
514 template <
class Derived>
515 template <
class OtherDerived>
518 derived() = derived() * other.
derived();
529 template <
class Derived>
538 Vector3 uv = this->vec().cross(v);
540 return v + this->
w() * uv + this->vec().cross(uv);
543 template<
class Derived>
546 coeffs() = other.
coeffs();
550 template<
class Derived>
551 template<
class OtherDerived>
554 coeffs() = other.
coeffs();
560 template<
class Derived>
567 this->vec() =
sin(ha) * aa.
axis();
577 template<
class Derived>
578 template<
class MatrixDerived>
582 YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
590 template<
class Derived>
600 const Scalar tx =
Scalar(2)*this->
x();
601 const Scalar ty =
Scalar(2)*this->
y();
602 const Scalar tz =
Scalar(2)*this->
z();
603 const Scalar twx = tx*this->
w();
604 const Scalar twy = ty*this->
w();
605 const Scalar twz = tz*this->
w();
606 const Scalar txx = tx*this->
x();
607 const Scalar txy = ty*this->
x();
608 const Scalar txz = tz*this->
x();
609 const Scalar tyy = ty*this->
y();
610 const Scalar tyz = tz*this->
y();
611 const Scalar tzz = tz*this->
z();
636 template<
class Derived>
637 template<
typename Derived1,
typename Derived2>
643 Scalar
c = v1.dot(v0);
658 Vector3 axis = svd.
matrixV().col(2);
661 this->
w() =
sqrt(w2);
665 Vector3 axis = v0.cross(v1);
668 this->vec() = axis * invs;
678 template<
typename Scalar,
int Options>
684 const Scalar u1 = internal::random<Scalar>(0, 1),
686 u3 = internal::random<Scalar>(0, 2*
EIGEN_PI);
703 template<
typename Scalar,
int Options>
704 template<
typename Derived1,
typename Derived2>
719 template <
class Derived>
723 Scalar
n2 = this->squaredNorm();
735 template<
int Arch,
class Derived,
typename Scalar>
struct quat_conj 749 template <
class Derived>
761 template <
class Derived>
762 template <
class OtherDerived>
779 template <
class Derived>
780 template <
class OtherDerived>
787 Scalar
d = this->
dot(other);
801 Scalar theta =
acos(absD);
802 Scalar sinTheta =
sin(theta);
804 scale0 =
sin( (
Scalar(1) - t ) * theta) / sinTheta;
805 scale1 =
sin( ( t * theta) ) / sinTheta;
807 if(d<
Scalar(0)) scale1 = -scale1;
815 template<
typename Other>
825 Scalar t = mat.trace();
831 q.
x() = (mat.coeff(2,1) - mat.coeff(1,2)) * t;
832 q.
y() = (mat.coeff(0,2) - mat.coeff(2,0)) * t;
833 q.
z() = (mat.coeff(1,0) - mat.coeff(0,1)) * t;
838 if (mat.coeff(1,1) > mat.coeff(0,0))
840 if (mat.coeff(2,2) > mat.coeff(i,i))
845 t =
sqrt(mat.coeff(i,i)-mat.coeff(j,j)-mat.coeff(k,k) +
Scalar(1.0));
848 q.
w() = (mat.coeff(k,j)-mat.coeff(j,k))*t;
849 q.
coeffs().coeffRef(j) = (mat.coeff(j,i)+mat.coeff(i,j))*t;
850 q.
coeffs().coeffRef(k) = (mat.coeff(k,i)+mat.coeff(i,k))*t;
856 template<
typename Other>
870 #endif // EIGEN_QUATERNION_H
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Map(const Scalar *coeffs)
EIGEN_DEVICE_FUNC Coefficients & coeffs()
internal::traits< Derived >::Coefficients Coefficients
cout<< "Here is the matrix m:"<< endl<< m<< endl;JacobiSVD< MatrixXf > svd(m, ComputeThinU|ComputeThinV)
#define EIGEN_STRONG_INLINE
EIGEN_DEVICE_FUNC CoeffReturnType x() const
Jet< T, N > cos(const Jet< T, N > &f)
NumTraits< Scalar >::Real RealScalar
Quaternion< _Scalar, _Options > PlainObject
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion(const QuaternionBase< Derived > &other)
EIGEN_DEVICE_FUNC const VectorBlock< const Coefficients, 3 > vec() const
A matrix or vector expression mapping an existing array of data.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Derived & operator*=(const QuaternionBase< OtherDerived > &q)
Matrix< Scalar, 3, 1 > Vector3
EIGEN_DEVICE_FUNC bool operator!=(const QuaternionBase< OtherDerived > &other) const
Quaternion< double > Quaterniond
EIGEN_DEVICE_FUNC const PlainObject normalized() const
const unsigned int LvalueBit
EIGEN_DEVICE_FUNC CoeffReturnType z() const
EIGEN_DEVICE_FUNC bool operator==(const QuaternionBase< OtherDerived > &other) const
Jet< T, N > acos(const Jet< T, N > &f)
Jet< T, N > sin(const Jet< T, N > &f)
Namespace containing all symbols from the Eigen library.
EIGEN_DEVICE_FUNC Quaternion(const Scalar &w, const Scalar &x, const Scalar &y, const Scalar &z)
EIGEN_DEVICE_FUNC CoeffReturnType w() const
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion< Scalar > run(const QuaternionBase< Derived > &q)
#define EIGEN_STATIC_ASSERT(CONDITION, MSG)
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T maxi(const T &x, const T &y)
#define EIGEN_DEFAULT_COPY_CONSTRUCTOR(CLASS)
AngleAxis< Scalar > AngleAxisType
EIGEN_DEVICE_FUNC const InverseReturnType inverse() const
Map< const Matrix< _Scalar, 4, 1 >, _Options > Coefficients
#define EIGEN_NOEXCEPT_IF(x)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar & coeffRef(Index rowId, Index colId)
EIGEN_DEVICE_FUNC internal::enable_if< internal::is_same< Scalar, NewScalarType >::value, const Derived & >::type cast() const
EIGEN_DEVICE_FUNC Quaternion(const MatrixBase< Derived > &other)
static EIGEN_DEVICE_FUNC void run(QuaternionBase< Derived > &q, const Other &vec)
EIGEN_DEVICE_FUNC Derived & setFromTwoVectors(const MatrixBase< Derived1 > &a, const MatrixBase< Derived2 > &b)
EIGEN_DEVICE_FUNC internal::enable_if<!internal::is_same< Scalar, NewScalarType >::value, Quaternion< NewScalarType > >::type cast() const
static EIGEN_STRONG_INLINE void _check_template_params()
cout<< "Here is the matrix m:"<< endl<< m<< endl;Matrix< ptrdiff_t, 3, 1 > res
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF(NeedsToAlign)
Expression of a fixed-size or dynamic-size sub-vector.
static EIGEN_DEVICE_FUNC Quaternion< Scalar > Identity()
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE internal::enable_if< NumTraits< T >::IsSigned||NumTraits< T >::IsComplex, typename NumTraits< T >::Real >::type abs(const T &x)
Scalar EIGEN_BLAS_FUNC() dot(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy)
EIGEN_DEVICE_FUNC void normalize()
EIGEN_DEVICE_FUNC VectorBlock< Coefficients, 3 > vec()
Map< Matrix< _Scalar, 4, 1 >, _Options > Coefficients
traits< Quaternion< _Scalar,(int(_Options)&Aligned)==Aligned ? AutoAlign :DontAlign > > TraitsBase
EIGEN_DEVICE_FUNC bool isApprox(const QuaternionBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
EIGEN_DEVICE_FUNC internal::traits< Derived >::Coefficients & coeffs()
static EIGEN_DEVICE_FUNC Matrix< Scalar, 2, 2 > toRotationMatrix(const Scalar &s)
EIGEN_DEVICE_FUNC Quaternion< Scalar > conjugate() const
EIGEN_DEVICE_FUNC const Derived & derived() const
EIGEN_DEVICE_FUNC Scalar angle() const
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion< Scalar > operator*(const QuaternionBase< OtherDerived > &q) const
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
static EIGEN_DEVICE_FUNC Quaternion FromTwoVectors(const MatrixBase< Derived1 > &a, const MatrixBase< Derived2 > &b)
EIGEN_DEVICE_FUNC Quaternion(const Scalar *data)
Array< int, Dynamic, 1 > v
EIGEN_DEVICE_FUNC Scalar norm() const
EIGEN_DEVICE_FUNC NewType cast(const OldType &x)
EIGEN_DEVICE_FUNC NonConstCoeffReturnType x()
Base::AngleAxisType AngleAxisType
EIGEN_DEVICE_FUNC Quaternion< Scalar > inverse() const
Common base class for compact rotation representations.
EIGEN_DEVICE_FUNC const internal::traits< Derived >::Coefficients & coeffs() const
EIGEN_DEVICE_FUNC const Scalar & q
#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Map(Scalar *coeffs)
EIGEN_DEVICE_FUNC Quaternion(const Quaternion< OtherScalar, OtherOptions > &other)
EIGEN_DEVICE_FUNC ConjugateReturnType conjugate() const
EIGEN_DEVICE_FUNC CoeffReturnType y() const
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorUInt128< uint64_t, uint64_t > operator*(const TensorUInt128< HL, LL > &lhs, const TensorUInt128< HR, LR > &rhs)
Coefficients::CoeffReturnType CoeffReturnType
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Vector3 _transformVector(const Vector3 &v) const
Base class for quaternion expressions.
internal::traits< Map >::Coefficients Coefficients
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE QuaternionBase< Derived > & operator=(const QuaternionBase< Derived > &other)
EIGEN_DEVICE_FUNC Quaternion(const AngleAxisType &aa)
EIGEN_DEVICE_FUNC NonConstCoeffReturnType y()
EIGEN_DEVICE_FUNC QuaternionBase & setIdentity()
const Coefficients m_coeffs
EIGEN_DEVICE_FUNC const Vector3 & axis() const
EIGEN_DEVICE_FUNC NonConstCoeffReturnType w()
QuaternionBase< Map< const Quaternion< _Scalar >, _Options > > Base
#define EIGEN_DEVICE_FUNC
Map< Quaternion< float >, 0 > QuaternionMapf
EIGEN_DEVICE_FUNC Coefficients & coeffs()
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 & operator*=(bfloat16 &a, const bfloat16 &b)
EIGEN_DEVICE_FUNC const Coefficients & coeffs() const
EIGEN_DEVICE_FUNC const Coefficients & coeffs() const
Matrix< _Scalar, 4, 1, _Options > Coefficients
EIGEN_DEVICE_FUNC NonConstCoeffReturnType z()
EIGEN_DEVICE_FUNC Quaternion()
The quaternion class used to represent 3D orientations and rotations.
#define EIGEN_USING_STD(FUNC)
#define EIGEN_DEFAULT_EMPTY_CONSTRUCTOR_AND_DESTRUCTOR(Derived)
RotationBase< Derived, 3 > Base
EIGEN_DEVICE_FUNC Scalar dot(const QuaternionBase< OtherDerived > &other) const
Map< Quaternion< double >, 0 > QuaternionMapd
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Map< Quaternion< float >, Aligned > QuaternionMapAlignedf
const AutoDiffScalar< Matrix< typename internal::traits< typename internal::remove_all< DerTypeA >::type >::Scalar, Dynamic, 1 > > atan2(const AutoDiffScalar< DerTypeA > &a, const AutoDiffScalar< DerTypeB > &b)
internal::traits< Quaternion >::Coefficients Coefficients
EIGEN_DEVICE_FUNC Scalar squaredNorm() const
EIGEN_DEVICE_FUNC Scalar angularDistance(const QuaternionBase< OtherDerived > &other) const
const MatrixVType & matrixV() const
Jet< T, N > sqrt(const Jet< T, N > &f)
EIGEN_DEVICE_FUNC const Coefficients & coeffs() const
EIGEN_DEVICE_FUNC Matrix3 toRotationMatrix() const
internal::traits< Map >::Coefficients Coefficients
Matrix< Scalar, 3, 3 > Matrix3
Generic expression where a coefficient-wise unary operator is applied to an expression.
static EIGEN_DEVICE_FUNC Quaternion UnitRandom()
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
internal::traits< Derived >::Scalar Scalar
Base class for all dense matrices, vectors, and expressions.
Represents a 3D rotation as a rotation angle around an arbitrary 3D axis.
static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Quaternion< Scalar > run(const QuaternionBase< Derived1 > &a, const QuaternionBase< Derived2 > &b)
QuaternionBase< Quaternion< _Scalar, _Options > > Base
Quaternion< float > Quaternionf
Map< Quaternion< double >, Aligned > QuaternionMapAlignedd
EIGEN_DEVICE_FUNC Quaternion< Scalar > slerp(const Scalar &t, const QuaternionBase< OtherDerived > &other) const
EIGEN_DEVICE_FUNC Quaternion< Scalar > normalized() const
Eigen::Quaternion< double, Eigen::DontAlign > Quaternion
QuaternionBase< Map< Quaternion< _Scalar >, _Options > > Base
static EIGEN_DEVICE_FUNC void run(QuaternionBase< Derived > &q, const Other &a_mat)