mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-28 14:54:11 +08:00
add normalization functions to Quaternion and fix compilation
issue with custom types
This commit is contained in:
parent
db030d4e28
commit
0940ad7127
@ -163,6 +163,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
inline Scalar norm() const { return m_coeffs.norm(); }
|
inline Scalar norm() const { return m_coeffs.norm(); }
|
||||||
|
|
||||||
|
/** Normalizes the quaternion \c *this
|
||||||
|
* \sa normalized(), MatrixBase::normalize() */
|
||||||
|
inline void normalize() { m_coeffs.normalize(); }
|
||||||
|
/** \returns a normalized version of \c *this
|
||||||
|
* \sa normalize(), MatrixBase::normalized() */
|
||||||
|
inline Quaternion normalized() const { Quaternion(m_coeffs.normalized()); }
|
||||||
|
|
||||||
/** \returns the dot product of \c *this and \a other
|
/** \returns the dot product of \c *this and \a other
|
||||||
* Geometrically speaking, the dot product of two unit quaternions
|
* Geometrically speaking, the dot product of two unit quaternions
|
||||||
* corresponds to the cosine of half the angle between the two rotations.
|
* corresponds to the cosine of half the angle between the two rotations.
|
||||||
@ -414,9 +421,9 @@ struct ei_quaternion_assign_impl<Other,3,3>
|
|||||||
Scalar t = mat.trace();
|
Scalar t = mat.trace();
|
||||||
if (t > 0)
|
if (t > 0)
|
||||||
{
|
{
|
||||||
t = ei_sqrt(t + 1.0);
|
t = ei_sqrt(t + Scalar(1.0));
|
||||||
q.w() = 0.5*t;
|
q.w() = Scalar(0.5)*t;
|
||||||
t = 0.5/t;
|
t = Scalar(0.5)/t;
|
||||||
q.x() = (mat.coeff(2,1) - mat.coeff(1,2)) * t;
|
q.x() = (mat.coeff(2,1) - mat.coeff(1,2)) * t;
|
||||||
q.y() = (mat.coeff(0,2) - mat.coeff(2,0)) * t;
|
q.y() = (mat.coeff(0,2) - mat.coeff(2,0)) * t;
|
||||||
q.z() = (mat.coeff(1,0) - mat.coeff(0,1)) * t;
|
q.z() = (mat.coeff(1,0) - mat.coeff(0,1)) * t;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user