mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-20 06:45:14 +03:00
Normalize all the line endings
This commit is contained in:
parent
4237370b60
commit
d60183d91d
396 changed files with 158300 additions and 158300 deletions
|
@ -1,76 +1,76 @@
|
|||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "maths.h"
|
||||
|
||||
int constrain(int amt, int low, int high)
|
||||
{
|
||||
if (amt < low)
|
||||
return low;
|
||||
else if (amt > high)
|
||||
return high;
|
||||
else
|
||||
return amt;
|
||||
}
|
||||
|
||||
float constrainf(float amt, float low, float high)
|
||||
{
|
||||
if (amt < low)
|
||||
return low;
|
||||
else if (amt > high)
|
||||
return high;
|
||||
else
|
||||
return amt;
|
||||
}
|
||||
|
||||
void devClear(stdev_t *dev)
|
||||
{
|
||||
dev->m_n = 0;
|
||||
}
|
||||
|
||||
void devPush(stdev_t *dev, float x)
|
||||
{
|
||||
dev->m_n++;
|
||||
if (dev->m_n == 1) {
|
||||
dev->m_oldM = dev->m_newM = x;
|
||||
dev->m_oldS = 0.0f;
|
||||
} else {
|
||||
dev->m_newM = dev->m_oldM + (x - dev->m_oldM) / dev->m_n;
|
||||
dev->m_newS = dev->m_oldS + (x - dev->m_oldM) * (x - dev->m_newM);
|
||||
dev->m_oldM = dev->m_newM;
|
||||
dev->m_oldS = dev->m_newS;
|
||||
}
|
||||
}
|
||||
|
||||
float devVariance(stdev_t *dev)
|
||||
{
|
||||
return ((dev->m_n > 1) ? dev->m_newS / (dev->m_n - 1) : 0.0f);
|
||||
}
|
||||
|
||||
float devStandardDeviation(stdev_t *dev)
|
||||
{
|
||||
return sqrtf(devVariance(dev));
|
||||
}
|
||||
|
||||
float degreesToRadians(int16_t degrees)
|
||||
{
|
||||
return degrees * RAD;
|
||||
}
|
||||
|
||||
/*
|
||||
* This file is part of Cleanflight.
|
||||
*
|
||||
* Cleanflight is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Cleanflight 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "maths.h"
|
||||
|
||||
int constrain(int amt, int low, int high)
|
||||
{
|
||||
if (amt < low)
|
||||
return low;
|
||||
else if (amt > high)
|
||||
return high;
|
||||
else
|
||||
return amt;
|
||||
}
|
||||
|
||||
float constrainf(float amt, float low, float high)
|
||||
{
|
||||
if (amt < low)
|
||||
return low;
|
||||
else if (amt > high)
|
||||
return high;
|
||||
else
|
||||
return amt;
|
||||
}
|
||||
|
||||
void devClear(stdev_t *dev)
|
||||
{
|
||||
dev->m_n = 0;
|
||||
}
|
||||
|
||||
void devPush(stdev_t *dev, float x)
|
||||
{
|
||||
dev->m_n++;
|
||||
if (dev->m_n == 1) {
|
||||
dev->m_oldM = dev->m_newM = x;
|
||||
dev->m_oldS = 0.0f;
|
||||
} else {
|
||||
dev->m_newM = dev->m_oldM + (x - dev->m_oldM) / dev->m_n;
|
||||
dev->m_newS = dev->m_oldS + (x - dev->m_oldM) * (x - dev->m_newM);
|
||||
dev->m_oldM = dev->m_newM;
|
||||
dev->m_oldS = dev->m_newS;
|
||||
}
|
||||
}
|
||||
|
||||
float devVariance(stdev_t *dev)
|
||||
{
|
||||
return ((dev->m_n > 1) ? dev->m_newS / (dev->m_n - 1) : 0.0f);
|
||||
}
|
||||
|
||||
float devStandardDeviation(stdev_t *dev)
|
||||
{
|
||||
return sqrtf(devVariance(dev));
|
||||
}
|
||||
|
||||
float degreesToRadians(int16_t degrees)
|
||||
{
|
||||
return degrees * RAD;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue