Koduino
Classes | Functions
Basic and advanced math

Detailed Description

Authors
Arduino team, Avik De avikd.nosp@m.e@gm.nosp@m.ail.c.nosp@m.om

This file is part of koduino https://github.com/avikde/koduino

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, see http://www.gnu.org/licenses/.

Classes

class  DLPF
 Digital autoregressive low pass filter. More...
 
class  PD
 Generic proportional-derivative control (for use in a motor, look at the Motor controller library instead) More...
 

Functions

void randomSeed (uint32_t dwSeed)
 
float map (float x, float in_min, float in_max, float out_min, float out_max)
 Map a float (different from Arduino implementation) More...
 
float interp1 (float from, float to, float frac)
 Linear interpolation between given endpoints. More...
 
float fmodf_mpi_pi (float f)
 Mod an angle to between -PI and PI. More...
 
float fmodf_0_2pi (float f)
 Mod an angle to between 0 and 2*PI. More...
 
float fmodf_0_1 (float f)
 Mod between 0 and 1. More...
 
float fmodf_mp5_p5 (float f)
 Mod between -0.5 and +0.5. More...
 
void circleMeanDiff (float a, float b, float *mean, float *diff)
 Change coords to mean and diff on a circle (accounting for wraparound) More...
 
void swapByte (uint8_t *a, uint8_t *b)
 Swaps the values pointed to be a and b.
 
void setOutPtrSafe (float *out, float val)
 Convenient function to safely (watch for NULL passed) set an output var. More...
 
void matMult (uint16_t nr1, uint16_t nc1, uint16_t nc2, float *m1, float *m2, float *mout)
 Use arm_mat_mult_f32 to multiply two matrices. More...
 

Function Documentation

void circleMeanDiff ( float  a,
float  b,
float *  mean,
float *  diff 
)

Change coords to mean and diff on a circle (accounting for wraparound)

Parameters
aFirst angle in rad
bSecond angle in rad
meanMean angle
diffDifference angle
float fmodf_0_1 ( float  f)

Mod between 0 and 1.

Parameters
fInput value
Returns
Result between 0 and 1
float fmodf_0_2pi ( float  f)

Mod an angle to between 0 and 2*PI.

Parameters
fInput angle
Returns
Result between 0 and 2*PI
float fmodf_mp5_p5 ( float  f)

Mod between -0.5 and +0.5.

Parameters
fInput value
Returns
Result between -0.5 and +0.5
float fmodf_mpi_pi ( float  f)

Mod an angle to between -PI and PI.

Parameters
fInput angle
Returns
Result between -PI and PI
float interp1 ( float  from,
float  to,
float  frac 
)

Linear interpolation between given endpoints.

Parameters
fromLower endpoint
toHigher endpoint
fracfloat between 0.0 and 1.0
Returns
Interpolated value
float map ( float  x,
float  in_min,
float  in_max,
float  out_min,
float  out_max 
)

Map a float (different from Arduino implementation)

Parameters
xValue to map
Returns
x mapped from [in_min, in_max] to [out_min, out_max]
void matMult ( uint16_t  nr1,
uint16_t  nc1,
uint16_t  nc2,
float *  m1,
float *  m2,
float *  mout 
)

Use arm_mat_mult_f32 to multiply two matrices.

Parameters
nr1Number of rows of M1
nc1Number of columns of M1 ( = number of rows of M2)
nc2Number of columns of M2
m1Pointer to contents of M1 (row major)
m2Pointer to contents of M2 (row major)
moutPreallocated array (nr1*nc2) for contents of M1*M2
void randomSeed ( uint32_t  dwSeed)

Part of the Wiring project - http://wiring.org.co Copyright (c) 2004-06 Hernando Barragan Modified by David A. Mellis for Arduino - http://www.arduino.cc/, Avik De avikd.nosp@m.e@gm.nosp@m.ail.c.nosp@m.om

This file is part of koduino https://github.com/avikde/koduino

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, see http://www.gnu.org/licenses/.

void setOutPtrSafe ( float *  out,
float  val 
)

Convenient function to safely (watch for NULL passed) set an output var.

Parameters
outOutput variable (pointer) which could be NULL
valValue to assign to output