23#ifndef VCL_SPACE_CORE_QUATERNION_H
24#define VCL_SPACE_CORE_QUATERNION_H
49template<
typename Scalar>
52 using Base = Eigen::Quaternion<Scalar>;
59 using Base::operator*;
60 using Base::operator*=;
73 template<
typename S,
int Options>
74 Quaternion(
const Eigen::Quaternion<S, Options>&
q) : Base(
q)
78 Quaternion(
const Scalar& angle,
const Point3<Scalar>& axis) :
79 Base(Eigen::AngleAxis<Scalar>(angle, axis))
83 Quaternion(
const Matrix44<Scalar>& rotMatrix) :
84 Base(Matrix33<Scalar>(rotMatrix.block(0, 0, 3, 3)))
101 Base::setFromTwoVectors(
a,
b);
118 if constexpr (std::is_same_v<Scalar, S>) {
126 constexpr uint size()
const {
return 4; }
130 void set(
const Scalar& w,
const Scalar& x,
const Scalar& y,
const Scalar& z)
138 void setFromAngleAxis(
const Scalar& angle,
const Point3<Scalar>& axis)
140 *
this = Base(Eigen::AngleAxis<Scalar>(angle, axis));
154 for (
size_t i = 0;
i < 4; ++
i)
155 hashCombine(
h, Base::operator()(
i));
170 Eigen::Matrix<Scalar, 3, 1>
fc = Base::vec().cross(
p);
172 Eigen::Matrix<Scalar, 3, 1>
fd =
p * Base::w();
174 Eigen::Matrix<Scalar, 3, 1> s =
fc +
fd;
176 Eigen::Matrix<Scalar, 3, 1>
sc = Base::vec().cross(s);
Quaternion class.
Definition quaternion.h:51
Quaternion()
Constructs a quaternion representing the identity rotation (w = 1, 0, 0, 0).
Definition quaternion.h:71
Quaternion(const Point3< Scalar > &a, const Point3< Scalar > &b)
Constructs the quaternion that will represent the rotation between the two arbitrary vectors a and b.
Definition quaternion.h:99
auto cast() const
Casts the Quaternion object to a different scalar type.
Definition quaternion.h:116
Point3< Scalar > operator*(const Point3< Scalar > &p) const
Quaternion-Vector multiplication.
Definition quaternion.h:168
std::size_t hash() const
Computes the hash value of the quaternion.
Definition quaternion.h:151
Scalar ScalarType
The Scalar type of the Quaternion.
Definition quaternion.h:65
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43