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.
int32_t math_2d_linear_interpolate_fast (int32_t x0, int32_t x1, int32_t y0, int32_t y1, int32_t x)
 Interpolate a value at a specific point from a 2D line.

Detailed Description

Macro Definition Documentation

◆ math_abs

#define math_abs ( x)

#include </__w/infuse-sdk/infuse-sdk/infuse-sdk/include/infuse/math/common.h>

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

Absolute value.

Parameters
xValue to absolute
Returns
Absolute value of x

Function Documentation

◆ math_2d_linear_interpolate_fast()

int32_t math_2d_linear_interpolate_fast ( int32_t x0,
int32_t x1,
int32_t y0,
int32_t y1,
int32_t x )

#include </__w/infuse-sdk/infuse-sdk/infuse-sdk/include/infuse/math/common.h>

Interpolate a value at a specific point from a 2D line.

The line is defined by two points, P0 and P1. Guaranteed for all values in the range [-23170, 23170]. Values outside of that range may overflow if all values are large.

Note
x0 and x1 MUST NOT be equal
Parameters
x0X coordinate of P0
x1X coordinate of P1
y0Y coordinate of P0
y1Y coordinate of P1
xValue to lookup
Returns
int32_t Interpolated value of the line at x

◆ 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 </__w/infuse-sdk/infuse-sdk/infuse-sdk/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 </__w/infuse-sdk/infuse-sdk/infuse-sdk/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 </__w/infuse-sdk/infuse-sdk/infuse-sdk/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 </__w/infuse-sdk/infuse-sdk/infuse-sdk/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 </__w/infuse-sdk/infuse-sdk/infuse-sdk/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 </__w/infuse-sdk/infuse-sdk/infuse-sdk/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 </__w/infuse-sdk/infuse-sdk/infuse-sdk/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 </__w/infuse-sdk/infuse-sdk/infuse-sdk/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 </__w/infuse-sdk/infuse-sdk/infuse-sdk/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 </__w/infuse-sdk/infuse-sdk/infuse-sdk/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 </__w/infuse-sdk/infuse-sdk/infuse-sdk/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)