Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Infuse-IoT Math libraries

Macros

#define math_abs(x)
 Absolute value.
 

Functions

uint8_t math_sqrt16 (uint16_t x)
 Compute square root of unsigned 16 bit number.
 
uint16_t math_sqrt32 (uint32_t x)
 Compute square root of unsigned 32 bit number.
 
uint32_t math_sqrt64 (uint64_t x)
 Compute square root of unsigned 64 bit number.
 
float math_inverse_sqrt32 (float x)
 Fast inverse square root.
 
uint32_t math_vector_xy_sq_magnitude (int16_t x, int16_t y)
 Compute the squared magnitude of an XY vector.
 
uint16_t math_vector_xy_magnitude (int16_t x, int16_t y)
 Compute the magnitude of an XY vector.
 
uint32_t math_vector_xyz_sq_magnitude (int16_t x, int16_t y, int16_t z)
 Compute the squared magnitude of an XYZ vector.
 
uint16_t math_vector_xyz_magnitude (int16_t x, int16_t y, int16_t z)
 Compute the magnitude of an XYZ vector.
 
int64_t math_vector_xyz_dot_product (int16_t ax, int16_t ay, int16_t az, int16_t bx, int16_t by, int16_t bz)
 Compute the dot product of two XYZ vectors.
 
int32_t math_vector_xyz_dot_product_fast (int16_t ax, int16_t ay, int16_t az, int16_t bx, int16_t by, int16_t bz)
 Compute the dot product of two XYZ vectors.
 
uint32_t math_bitmask_get_next_bits (uint32_t bitmask, uint8_t start_idx, uint8_t *next_idx, uint8_t num_bits)
 Get the next N bits of a bitmask, with rollover.
 

Detailed Description

Macro Definition Documentation

◆ math_abs

#define math_abs ( x)

#include <infuse/math/common.h>

Value:
((x) < 0 ? -(x) : (x))

Absolute value.

Parameters
xValue to absolute
Returns
Absolute value of x

Function Documentation

◆ math_bitmask_get_next_bits()

uint32_t math_bitmask_get_next_bits ( uint32_t bitmask,
uint8_t start_idx,
uint8_t * next_idx,
uint8_t num_bits )

#include <infuse/math/common.h>

Get the next N bits of a bitmask, with rollover.

Parameters
bitmaskBitmask to iterate over
start_idxIndex of first bit to check
next_idxIndex of first bit to check on next iteration
num_bitsNumber of bits to return
Returns
uint32_t N bits from bitmask

◆ math_inverse_sqrt32()

float math_inverse_sqrt32 ( float x)

#include <infuse/math/common.h>

Fast inverse square root.

Parameters
xValue to compute inverse square root of
Returns
float Inverse square root (1 / sqrt(x))

◆ math_sqrt16()

uint8_t math_sqrt16 ( uint16_t x)

#include <infuse/math/common.h>

Compute square root of unsigned 16 bit number.

Parameters
xValue to square root
Returns
uint8_t Square root of number

◆ math_sqrt32()

uint16_t math_sqrt32 ( uint32_t x)

#include <infuse/math/common.h>

Compute square root of unsigned 32 bit number.

Parameters
xValue to square root
Returns
uint16_t Square root of number

◆ math_sqrt64()

uint32_t math_sqrt64 ( uint64_t x)

#include <infuse/math/common.h>

Compute square root of unsigned 64 bit number.

Parameters
xValue to square root
Returns
uint16_t Square root of number

◆ math_vector_xy_magnitude()

uint16_t math_vector_xy_magnitude ( int16_t x,
int16_t y )

#include <infuse/math/common.h>

Compute the magnitude of an XY vector.

Parameters
xX component of vector
yY component of vector
Returns
uint16_t Magnitude of vector sqrt(x*x + y*y)

◆ math_vector_xy_sq_magnitude()

uint32_t math_vector_xy_sq_magnitude ( int16_t x,
int16_t y )

#include <infuse/math/common.h>

Compute the squared magnitude of an XY vector.

Parameters
xX component of vector
yY component of vector
Returns
uint16_t Squared magnitude of vector (x*x + y*y)

◆ math_vector_xyz_dot_product()

int64_t math_vector_xyz_dot_product ( int16_t ax,
int16_t ay,
int16_t az,
int16_t bx,
int16_t by,
int16_t bz )

#include <infuse/math/common.h>

Compute the dot product of two XYZ vectors.

The maximum value of the output is 1.5 * (2 ** 31), when all inputs are INT16_MIN.

Parameters
axA vector, X component
ayA vector, Y component
azA vector, Z component
bxB vector, X component
byB vector, Y component
bzB vector, Z component
Returns
int64_t Dot product of the two vectors

◆ math_vector_xyz_dot_product_fast()

int32_t math_vector_xyz_dot_product_fast ( int16_t ax,
int16_t ay,
int16_t az,
int16_t bx,
int16_t by,
int16_t bz )

#include <infuse/math/common.h>

Compute the dot product of two XYZ vectors.

A faster variant of math_vector_xyz_dot_product that assumes the dot product fits in an int32_t, which will be true for most, but not all, inputs.

Parameters
axA vector, X component
ayA vector, Y component
azA vector, Z component
bxB vector, X component
byB vector, Y component
bzB vector, Z component
Returns
int32_t Dot product of the two vectors

◆ math_vector_xyz_magnitude()

uint16_t math_vector_xyz_magnitude ( int16_t x,
int16_t y,
int16_t z )

#include <infuse/math/common.h>

Compute the magnitude of an XYZ vector.

Parameters
xX component of vector
yY component of vector
zZ component of vector
Returns
uint16_t Magnitude of vector sqrt(x*x + y*y + z*z)

◆ math_vector_xyz_sq_magnitude()

uint32_t math_vector_xyz_sq_magnitude ( int16_t x,
int16_t y,
int16_t z )

#include <infuse/math/common.h>

Compute the squared magnitude of an XYZ vector.

Parameters
xX component of vector
yY component of vector
zZ component of vector
Returns
uint16_t Squared magnitude of vector (x*x + y*y + z*z)