AP_Math: allow vector3 and matrix3 objects to be used as arrays

This commit is contained in:
Andrew Tridgell 2013-12-29 18:37:14 +11:00
parent 519a26691e
commit 828eed1984
2 changed files with 12 additions and 0 deletions

View File

@ -125,6 +125,12 @@ public:
return *this = *this / num;
}
// allow a Matrix3 to be used as an array of vectors, 0 indexed
Vector3<T> & operator[](uint8_t i) {
Vector3<T> *_v = &a;
return _v[i];
}
// multiplication by a vector
Vector3<T> operator *(const Vector3<T> &v) const;

View File

@ -111,6 +111,12 @@ public:
// uniform scaling
Vector3<T> &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<T> &v) const;