Skip to content

Commit

Permalink
AP_Math: move zeroing to header, use memset, reuse in identity
Browse files Browse the repository at this point in the history
this method is in ITCM memory on STM32 - which makes small optimisations worthwhile
  • Loading branch information
peterbarker authored and tridge committed Nov 4, 2024
1 parent 4e0930a commit dc62483
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 0 additions & 8 deletions libraries/AP_Math/matrix3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
8 changes: 4 additions & 4 deletions libraries/AP_Math/matrix3.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,14 @@ class Matrix3 {
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
Expand Down

0 comments on commit dc62483

Please sign in to comment.