diff --git a/libraries/AP_Math/matrix3.h b/libraries/AP_Math/matrix3.h index 34ddadb754..21618d1da3 100644 --- a/libraries/AP_Math/matrix3.h +++ b/libraries/AP_Math/matrix3.h @@ -125,6 +125,12 @@ public: return *this = *this / num; } + // allow a Matrix3 to be used as an array of vectors, 0 indexed + Vector3 & operator[](uint8_t i) { + Vector3 *_v = &a; + return _v[i]; + } + // multiplication by a vector Vector3 operator *(const Vector3 &v) const; diff --git a/libraries/AP_Math/vector3.h b/libraries/AP_Math/vector3.h index 83b31a6b90..403b62e50b 100644 --- a/libraries/AP_Math/vector3.h +++ b/libraries/AP_Math/vector3.h @@ -111,6 +111,12 @@ public: // uniform scaling Vector3 &operator /=(const T num); + // allow a vector3 to be used as an array, 0 indexed + T & operator[](uint8_t i) { + T *_v = &x; + return _v[i]; + } + // dot product T operator *(const Vector3 &v) const;