AP_Math: move zeroing to header, use memset, reuse in identity

this method is in ITCM memory on STM32 - which makes small optimisations worthwhile
This commit is contained in:
Peter Barker 2024-10-17 13:33:22 +11:00 committed by Andrew Tridgell
parent 4e0930a09d
commit dc62483e0c
2 changed files with 4 additions and 12 deletions

View File

@ -227,14 +227,6 @@ bool Matrix3<T>::invert()
return success;
}
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;
}
// create rotation matrix for rotation about the vector v by angle theta
// See: http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToMatrix/
template <typename T>

View File

@ -219,14 +219,14 @@ public:
bool invert() WARN_IF_UNUSED;
// zero the matrix
void zero(void);
void zero(void) {
memset((void*)this, 0, sizeof(*this));
}
// setup the identity matrix
void identity(void) {
zero();
a.x = b.y = c.z = 1;
a.y = a.z = 0;
b.x = b.z = 0;
c.x = c.y = 0;
}
// check if any elements are NAN