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; 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 // create rotation matrix for rotation about the vector v by angle theta
// See: http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToMatrix/ // See: http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToMatrix/
template <typename T> template <typename T>

View File

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