mirror of https://github.com/ArduPilot/ardupilot
Math: moved more template functions to the .cpp files
save a bit more code space for larger functions
This commit is contained in:
parent
93e8bee44e
commit
f23cebc808
|
@ -188,12 +188,30 @@ Matrix3<T> Matrix3<T>::operator *(const Matrix3<T> &m) const
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
Matrix3<T> Matrix3<T>::transposed(void) const
|
||||||
|
{
|
||||||
|
return Matrix3<T>(Vector3<T>(a.x, b.x, c.x),
|
||||||
|
Vector3<T>(a.y, b.y, c.y),
|
||||||
|
Vector3<T>(a.z, b.z, c.z));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void Matrix3<T>::zero(void)
|
||||||
|
{
|
||||||
|
a.x = a.y = a.z = 0;
|
||||||
|
b.x = b.y = b.z = 0;
|
||||||
|
c.x = c.y = c.z = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// only define for float
|
// only define for float
|
||||||
template void Matrix3<float>::rotation(enum Rotation);
|
template void Matrix3<float>::rotation(enum Rotation);
|
||||||
|
template void Matrix3<float>::zero(void);
|
||||||
template void Matrix3<float>::rotate(const Vector3<float> &g);
|
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>::from_euler(float roll, float pitch, float yaw);
|
||||||
template void Matrix3<float>::to_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>::operator *(const Vector3<float> &v) const;
|
||||||
template Vector3<float> Matrix3<float>::mul_transpose(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;
|
template Matrix3<float> Matrix3<float>::operator *(const Matrix3<float> &m) const;
|
||||||
|
template Matrix3<float> Matrix3<float>::transposed(void) const;
|
||||||
|
|
|
@ -102,21 +102,13 @@ public:
|
||||||
{ return *this = *this * m; }
|
{ return *this = *this * m; }
|
||||||
|
|
||||||
// transpose the matrix
|
// transpose the matrix
|
||||||
Matrix3<T> transposed(void) const
|
Matrix3<T> transposed(void) const;
|
||||||
{
|
|
||||||
return Matrix3<T>(Vector3<T>(a.x, b.x, c.x),
|
|
||||||
Vector3<T>(a.y, b.y, c.y),
|
|
||||||
Vector3<T>(a.z, b.z, c.z));
|
|
||||||
}
|
|
||||||
Matrix3<T> transpose(void)
|
Matrix3<T> transpose(void)
|
||||||
{ return *this = transposed(); }
|
{ return *this = transposed(); }
|
||||||
|
|
||||||
// zero the matrix
|
// zero the matrix
|
||||||
void zero(void) {
|
void zero(void);
|
||||||
a.x = a.y = a.z = 0;
|
|
||||||
b.x = b.y = b.z = 0;
|
|
||||||
c.x = c.y = c.z = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// setup the identity matrix
|
// setup the identity matrix
|
||||||
void identity(void) {
|
void identity(void) {
|
||||||
|
|
|
@ -109,7 +109,26 @@ void Vector3<T>::rotate(enum Rotation rotation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
Vector3<T> Vector3<T>::operator %(const Vector3<T> &v) const
|
||||||
|
{
|
||||||
|
Vector3<T> temp(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x);
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// dot product
|
||||||
|
template <typename T>
|
||||||
|
T Vector3<T>::operator *(const Vector3<T> &v) const
|
||||||
|
{ return x*v.x + y*v.y + z*v.z; }
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
float Vector3<T>::length(void) const
|
||||||
|
{
|
||||||
|
return (T)sqrt(*this * *this);
|
||||||
|
}
|
||||||
|
|
||||||
// only define for signed numbers
|
// only define for signed numbers
|
||||||
template void Vector3<float>::rotate(enum Rotation);
|
template void Vector3<float>::rotate(enum Rotation);
|
||||||
template void Vector3<int16_t>::rotate(enum Rotation);
|
template float Vector3<float>::length(void) const;
|
||||||
template void Vector3<int32_t>::rotate(enum Rotation);
|
template Vector3<float> Vector3<float>::operator %(const Vector3<float> &v) const;
|
||||||
|
template float Vector3<float>::operator *(const Vector3<float> &v) const;
|
||||||
|
|
|
@ -123,23 +123,17 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// dot product
|
// dot product
|
||||||
T operator *(const Vector3<T> &v) const
|
T operator *(const Vector3<T> &v) const;
|
||||||
{ return x*v.x + y*v.y + z*v.z; }
|
|
||||||
|
|
||||||
// cross product
|
// cross product
|
||||||
Vector3<T> operator %(const Vector3<T> &v) const
|
Vector3<T> operator %(const Vector3<T> &v) const;
|
||||||
{
|
|
||||||
Vector3<T> temp(y*v.z - z*v.y, z*v.x - x*v.z, x*v.y - y*v.x);
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// gets the length of this vector squared
|
// gets the length of this vector squared
|
||||||
T length_squared() const
|
T length_squared() const
|
||||||
{ return (T)(*this * *this); }
|
{ return (T)(*this * *this); }
|
||||||
|
|
||||||
// gets the length of this vector
|
// gets the length of this vector
|
||||||
float length() const
|
float length(void) const;
|
||||||
{ return (T)sqrt(*this * *this); }
|
|
||||||
|
|
||||||
// normalizes this vector
|
// normalizes this vector
|
||||||
void normalize()
|
void normalize()
|
||||||
|
|
Loading…
Reference in New Issue