Hummingbird Flight Software
Flight software for the Hummingbird FCU quadcopter flight controller. Designed to run on the Teensy 4.1. Developed with VSCode+PlatformIO.
Functions
math_functs.h File Reference
#include <Arduino.h>
#include <math.h>
#include <float.h>
#include "constants.h"
#include "hummingbird_config.h"

Go to the source code of this file.

Functions

float InvSqrtf (float num)
 Extra math functions such as fast square root, 'safe' trig. More...
 
template<typename T >
RangeConstrain (const T val, const T lower, const T upper)
 Templates to constrain a value to a certain range. More...
 
template<typename T >
float sqrtf_safe (const T val)
 Compute safe square root of a value. More...
 
template<typename T >
float asinf_safe (const T val)
 Take the arcsine of a number with safety checks. More...
 

Function Documentation

◆ asinf_safe()

template<typename T >
float asinf_safe ( const T  val)

Take the arcsine of a number with safety checks.

Return float

Parameters
valValue to take the arcsine of
Returns
(float) Computed arcsine.

◆ InvSqrtf()

float InvSqrtf ( float  num)

Extra math functions such as fast square root, 'safe' trig.

functions, etc.

functions, etc. norm = a * InvSqrtf(a); Fast inverse square root algorithm. Use when normalizing vectors! See: https://en.wikipedia.org/wiki/Fast_inverse_square_root

Parameters
numNumber to square-root.
Returns
Inverse of square root.

◆ RangeConstrain()

template<typename T >
T RangeConstrain ( const T  val,
const T  lower,
const T  upper 
)

Templates to constrain a value to a certain range.

Works for floats, uint16, etc. If value is out of specified bounds, constrain it to be within the bounds.

Parameters
valInput value to constrain
lowerLower bound
upperUpper bound

◆ sqrtf_safe()

template<typename T >
float sqrtf_safe ( const T  val)

Compute safe square root of a value.

Checks for NaN's

Parameters
valValue to take square root of.
Returns
Square root of result.