diff --git a/libraries/AP_Math/matrix3.cpp b/libraries/AP_Math/matrix3.cpp index df3f7442b2..d6dcd0743c 100644 --- a/libraries/AP_Math/matrix3.cpp +++ b/libraries/AP_Math/matrix3.cpp @@ -59,6 +59,19 @@ void Matrix3::to_euler(float *roll, float *pitch, float *yaw) const } } +template +void Matrix3::from_rotation(enum Rotation rotation) +{ + (*this).a(1,0,0); + (*this).b(0,1,0); + (*this).c(0,0,1); + + (*this).a.rotate(rotation); + (*this).b.rotate(rotation); + (*this).c.rotate(rotation); + (*this).transpose(); +} + /* calculate Euler angles (312 convention) for the matrix. See http://www.atacolorado.com/eulersequences.doc @@ -260,6 +273,7 @@ template void Matrix3::rotate(const Vector3 &g); template void Matrix3::normalize(void); template void Matrix3::from_euler(float roll, float pitch, float yaw); template void Matrix3::to_euler(float *roll, float *pitch, float *yaw) const; +template void Matrix3::from_rotation(enum Rotation rotation); template void Matrix3::from_euler312(float roll, float pitch, float yaw); template void Matrix3::from_axis_angle(const Vector3 &v, float theta); template Vector3 Matrix3::to_euler312(void) const; diff --git a/libraries/AP_Math/matrix3.h b/libraries/AP_Math/matrix3.h index 024b883dd3..6c58c8c52e 100644 --- a/libraries/AP_Math/matrix3.h +++ b/libraries/AP_Math/matrix3.h @@ -235,6 +235,9 @@ public: // create eulers from a rotation matrix void to_euler(float *roll, float *pitch, float *yaw) const; + // create matrix from rotation enum + void from_rotation(enum Rotation rotation); + /* calculate Euler angles (312 convention) for the matrix. See http://www.atacolorado.com/eulersequences.doc