Skip to content

Commit

Permalink
Quaternion: fix earth_to_body
Browse files Browse the repository at this point in the history
Previously, this function did nothing. It was also trying to do the
opposite of what it claimed to do.
  • Loading branch information
robertlong13 authored and meee1 committed Feb 3, 2025
1 parent 07b2f9b commit 010bbeb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ExtLibs/Utilities/Quaternion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,18 @@ private double sqrtf(double v)
return Math.Sqrt(v);
}

// convert a vector from earth to body frame
public void earth_to_body(Vector3f v)
// convert a vector from body to earth frame
public Vector3f body_to_earth(Vector3f v)
{
Matrix3 m = new Matrix3();
rotation_matrix(m);
v = m * v;
return m * v;
}

// convert a vector from earth to body frame
public Vector3f earth_to_body(Vector3f v)
{
return inverse().body_to_earth(v);
}

// create a quaternion from Euler angles
Expand Down

0 comments on commit 010bbeb

Please sign in to comment.