Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
Quaternion mark const helpers const
Browse files Browse the repository at this point in the history
  • Loading branch information
dagar authored and jgoppert committed Apr 1, 2018
1 parent e7c95fa commit 21d4742
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions matrix/Quaternion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,9 @@ class Quaternion : public Vector<Type, 4>
*
* @return inverted quaternion
*/
Quaternion inversed()
Quaternion inversed() const
{
Quaternion &q = *this;
const Quaternion &q = *this;
Type normSq = q.dot(q);
return Quaternion(
q(0)/normSq,
Expand Down Expand Up @@ -393,7 +393,8 @@ class Quaternion : public Vector<Type, 4>
* @param vec vector to rotate in frame 2 (typically reference frame)
* @return rotated vector in frame 1 (typically body frame)
*/
Vector3f conjugate_inversed(const Vector3f &vec) {
Vector3f conjugate_inversed(const Vector3f &vec) const
{
Quaternion q = *this;
Quaternion v(0, vec(0), vec(1), vec(2));
Quaternion res = q.inversed()*v*q;
Expand Down Expand Up @@ -459,9 +460,9 @@ class Quaternion : public Vector<Type, 4>
*
* @return vector, direction representing rotation axis and norm representing angle
*/
Vector<Type, 3> to_axis_angle()
Vector<Type, 3> to_axis_angle() const
{
Quaternion &q = *this;
const Quaternion &q = *this;
Type axis_magnitude = Type(sqrt(q(1) * q(1) + q(2) * q(2) + q(3) * q(3)));
Vector<Type, 3> vec;
vec(0) = q(1);
Expand All @@ -479,9 +480,9 @@ class Quaternion : public Vector<Type, 4>
/**
* Imaginary components of quaternion
*/
Vector3<Type> imag()
Vector3<Type> imag() const
{
Quaternion &q = *this;
const Quaternion &q = *this;
return Vector3<Type>(q(1), q(2), q(3));
}

Expand All @@ -492,9 +493,9 @@ class Quaternion : public Vector<Type, 4>
* == last column of the equivalent rotation matrix
* but calculated more efficiently than a full conversion
*/
Vector3<Type> dcm_z()
Vector3<Type> dcm_z() const
{
Quaternion &q = *this;
const Quaternion &q = *this;
Vector3<Type> R_z;
const Type a = q(0);
const Type b = q(1);
Expand Down

0 comments on commit 21d4742

Please sign in to comment.