25 #ifndef FIBER_QUATERNION_H_
26 #define FIBER_QUATERNION_H_
31 template <
typename Scalar>
48 Scalar
w()
const {
return data_[0]; }
51 Scalar
x()
const {
return data_[1]; }
54 Scalar
y()
const {
return data_[2]; }
57 Scalar
z()
const {
return data_[3]; }
60 assert(0 <= i && i < 4);
65 assert(0 <= i && i < 4);
70 assert(0 <= i && i < 4);
78 for (
int i = 0; i < 3; i++) {
92 template <
typename Exp>
94 assert(exp.
size() == 4);
95 for (
int i = 0; i < 4; i++) {
109 template <
int... Axes>
114 template <
typename Exp>
116 assert(exp.
size() == 4);
117 for (
int i = 0; i < 4; i++) {
135 template <
int... Axes>
141 template <
typename Exp>
143 assert(exp.
size() == 3);
145 return fiber::GetRows<3>((*this) * projected *
Conjugate(*
this), 1);
149 template <
typename Scalar>
165 template <
typename Scalar>
169 q_A[0] * q_B[0] - q_A[1] * q_B[1] - q_A[2] * q_B[2] - q_A[3] * q_B[3],
170 q_A[1] * q_B[0] + q_A[0] * q_B[1] - q_A[3] * q_B[2] + q_A[2] * q_B[3],
171 q_A[2] * q_B[0] + q_A[3] * q_B[1] + q_A[0] * q_B[2] - q_A[1] * q_B[3],
172 q_A[3] * q_B[0] - q_A[2] * q_B[1] + q_A[1] * q_B[2] + q_A[0] * q_B[3]);
188 #endif // FIBER_QUATERNION_H_
void EulerAnglesToQuaternion(const euler::Angles< Scalar, Axis1, Axis2, Axis3 > &euler, Quaternion< Scalar > *q)
Quaternion(const AxisAngle< Scalar > &axis_angle)
expression template for rvalues
Quaternion< Scalar > & operator=(const AxisAngle< Scalar > &axis_angle)
Quaternion< float > Quaternionf
Quaternion< Scalar > & operator=(const CoordinateAxisAngle< Scalar, Axis > &axis_angle)
Scalar operator()(Size i, Size j) const
void AxisAngleToQuaternion(const fiber::_RValue< Scalar, Exp > &axis, const Scalar angle, Quaternion< Scalar > *q)
Matrix< Scalar, 3, 1 > Rotate(const fiber::_RValue< Scalar, Exp > &exp) const
void CoordinateAxisAngleToQuaternion(const CoordinateAxisAngle< Scalar, Axis > &axis_angle, Quaternion< Scalar > *q)
Quaternion()
Default constructor, identity quaternion.
A vector of euler angles.
An axis angle rotation about a coordinate axis.
Scalar operator[](Size i) const
Quaternion< Scalar > & operator=(const euler::Angles< Scalar, Axes...> &euler)
Quaternion< Scalar > & operator=(const fiber::_RValue< Scalar, Exp > &exp)
Quaternion(Scalar w, Scalar x, Scalar y, Scalar z)
inline constructor
Quaternion(const fiber::_RValue< Scalar, Exp > &exp)
Construct from any MatrixExpression, copies elements.
Quaternion(const CoordinateAxisAngle< Scalar, Axis > &axis_angle)
Scalar & operator[](Size i)
Encodes a rotation in 3-dimensions by an return RView<Scalar, Exp, rows, Exp::COLS>(static_cast<Exp c...
Quaternion< Scalar > Conjugate(Quaternion< Scalar > const &q)
Matrix< Scalar, Exp1::ROWS_, Exp2::COLS_ > operator*(_RValue< Scalar, Exp1 > const &A, _RValue< Scalar, Exp2 > const &B)
Matrix multiplication.
Quaternion(const euler::Angles< Scalar, Axes...> &euler)
Quaternion< double > Quaterniond