Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions libs/openFrameworks/math/ofQuaternion.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ class ofQuaternion {
inline float length() const;

/// \brief Length of the quaternion = vec . vec
inline float length2() const;

inline float lengthSquared() const;
[[deprecated("use lengthSquare")]] inline float length2() const { return lengthSquared(); };

/// \brief Conjugate
inline ofQuaternion conj() const;

Expand Down Expand Up @@ -459,13 +460,11 @@ float ofQuaternion::length() const {
return std::sqrt(_v.x*_v.x + _v.y*_v.y + _v.z*_v.z + _v.w*_v.w);
}


//----------------------------------------
float ofQuaternion::length2() const {
return _v.x*_v.x + _v.y*_v.y + _v.z*_v.z + _v.w*_v.w;
float ofQuaternion::lengthSquared() const {
return _v.x*_v.x + _v.y*_v.y + _v.z*_v.z + _v.w*_v.w;
}


//----------------------------------------
ofQuaternion ofQuaternion::conj() const {
return ofQuaternion(-_v.x, -_v.y, -_v.z, _v.w);
Expand All @@ -474,7 +473,7 @@ ofQuaternion ofQuaternion::conj() const {

//----------------------------------------
const ofQuaternion ofQuaternion::inverse() const {
return conj() / length2();
return conj() / lengthSquared();
}


Expand Down