Math: added mul_transpose() operation

this is equivalent to multiplying by m.transposed(), but is more
efficient
This commit is contained in:
Andrew Tridgell 2012-03-23 14:58:54 +11:00
parent f1acdb13c2
commit a6d66dc45b
2 changed files with 13 additions and 0 deletions

View File

@ -163,6 +163,15 @@ Vector3<T> Matrix3<T>::operator *(const Vector3<T> &v) const
c.x * v.x + c.y * v.y + c.z * v.z);
}
// multiplication of transpose by a vector
template <typename T>
Vector3<T> Matrix3<T>::mul_transpose(const Vector3<T> &v) const
{
return Vector3<T>(a.x * v.x + b.x * v.y + c.x * v.z,
a.y * v.x + b.y * v.y + c.y * v.z,
a.z * v.x + b.z * v.y + c.z * v.z);
}
// multiplication by another Matrix3<T>
template <typename T>
Matrix3<T> Matrix3<T>::operator *(const Matrix3<T> &m) const
@ -186,4 +195,5 @@ template void Matrix3<float>::rotate(const Vector3<float> &g);
template void Matrix3<float>::from_euler(float roll, float pitch, float yaw);
template void Matrix3<float>::to_euler(float *roll, float *pitch, float *yaw);
template Vector3<float> Matrix3<float>::operator *(const Vector3<float> &v) const;
template Vector3<float> Matrix3<float>::mul_transpose(const Vector3<float> &v) const;
template Matrix3<float> Matrix3<float>::operator *(const Matrix3<float> &m) const;

View File

@ -92,6 +92,9 @@ public:
// multiplication by a vector
Vector3<T> operator *(const Vector3<T> &v) const;
// multiplication of transpose by a vector
Vector3<T> mul_transpose(const Vector3<T> &v) const;
// multiplication by another Matrix3<T>
Matrix3<T> operator *(const Matrix3<T> &m) const;