Hummingbird Flight Software
Flight software for the Hummingbird FCU quadcopter flight controller. Designed to run on the Teensy 4.1. Developed with VSCode+PlatformIO.
math_functs.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // EXTRA MATH FUNCTIONS
3 //
4 // Code By: Michael Wrona | B.S. Aerospace Engineering
5 // Created:
6 // ----------------------------------------------------------------------------
11 #pragma once
12 
13 #include <Arduino.h>
14 #include <math.h>
15 #include <float.h>
16 #include "constants.h"
17 #include "hummingbird_config.h"
18 
19 
20 float InvSqrtf(float num); // Used for normalizing
21 
22 template <typename T>
23 T RangeConstrain(const T val, const T lower, const T upper); // Constrain value to a range
24 
25 template <typename T>
26 float sqrtf_safe(const T val); // Check for computational errors in sqrt
27 
28 template <typename T>
29 float asinf_safe(const T val); // Take arcsine with checks
30 
31 // template <typename T>
32 // float acosf_safe(const T val); // Take arccosine with checks
float sqrtf_safe(const T val)
Compute safe square root of a value.
Definition: math_functs.cpp:91
float asinf_safe(const T val)
Take the arcsine of a number with safety checks.
Definition: math_functs.cpp:115
float InvSqrtf(float num)
Extra math functions such as fast square root, 'safe' trig.
Definition: math_functs.cpp:27
T RangeConstrain(const T val, const T lower, const T upper)
Templates to constrain a value to a certain range.
Definition: math_functs.cpp:56