From 11568c77d49285b7ea376e2696cdce1fdb57d13c Mon Sep 17 00:00:00 2001 From: Johan Jansen Date: Sun, 8 Mar 2015 12:14:47 +0100 Subject: VectorMath: Add scalar division to custom EKF vector math --- src/modules/ekf_att_pos_estimator/estimator_utilities.cpp | 10 ++++++++++ src/modules/ekf_att_pos_estimator/estimator_utilities.h | 1 + 2 files changed, 11 insertions(+) (limited to 'src/modules/ekf_att_pos_estimator') diff --git a/src/modules/ekf_att_pos_estimator/estimator_utilities.cpp b/src/modules/ekf_att_pos_estimator/estimator_utilities.cpp index e2f4c7e82..64a25aaba 100644 --- a/src/modules/ekf_att_pos_estimator/estimator_utilities.cpp +++ b/src/modules/ekf_att_pos_estimator/estimator_utilities.cpp @@ -198,3 +198,13 @@ void swap_var(float &d1, float &d2) d1 = d2; d2 = tmp; } + +// overload / operator to provide a vector scalar division +Vector3f operator/(const Vector3f &vec, const float scalar) +{ + Vector3f vecOut; + vecOut.x = vec.x / scalar; + vecOut.y = vec.y / scalar; + vecOut.z = vec.z / scalar; + return vecOut; +} diff --git a/src/modules/ekf_att_pos_estimator/estimator_utilities.h b/src/modules/ekf_att_pos_estimator/estimator_utilities.h index 95b83ead4..b2d790e27 100644 --- a/src/modules/ekf_att_pos_estimator/estimator_utilities.h +++ b/src/modules/ekf_att_pos_estimator/estimator_utilities.h @@ -89,6 +89,7 @@ Vector3f operator*( Mat3f matIn, Vector3f vecIn); Mat3f operator*( Mat3f matIn1, Mat3f matIn2); Vector3f operator%( Vector3f vecIn1, Vector3f vecIn2); Vector3f operator*(Vector3f vecIn1, float sclIn1); +Vector3f operator/(const Vector3f &vec, const float scalar); void swap_var(float &d1, float &d2); -- cgit v1.2.3