2017-12-09 12:23:18 -05:00
|
|
|
#ifndef AVERAGEANGLE_H
|
|
|
|
#define AVERAGEANGLE_H
|
|
|
|
//
|
|
|
|
// FILE: AverageAngle.h
|
|
|
|
// AUTHOR: Rob dot Tillaart at gmail dot com
|
2018-04-02 12:51:08 -04:00
|
|
|
// VERSION: 0.1.2
|
2017-12-09 12:23:18 -05:00
|
|
|
// PURPOSE: class for averaging angles
|
|
|
|
// HISTORY: See AverageAngle.cpp
|
|
|
|
//
|
|
|
|
// Released to the public domain
|
|
|
|
//
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#if defined(ARDUINO) && ARDUINO >= 100
|
|
|
|
#include "Arduino.h"
|
|
|
|
#else
|
|
|
|
#include "WProgram.h"
|
|
|
|
#endif
|
|
|
|
|
2018-04-02 12:51:08 -04:00
|
|
|
#define AVERAGE_ANGLE_LIB_VERSION "0.1.2"
|
2017-12-09 12:23:18 -05:00
|
|
|
|
|
|
|
class AverageAngle
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum AngleType { DEGREES, RADIANS };
|
|
|
|
|
|
|
|
AverageAngle(const enum AngleType type = DEGREES);
|
|
|
|
|
|
|
|
void add(float alpha, float length = 1.0);
|
|
|
|
void reset();
|
|
|
|
int count() { return _count; };
|
|
|
|
float getAverage();
|
2018-04-02 12:51:08 -04:00
|
|
|
|
|
|
|
float getTotalLength();
|
|
|
|
float getAverageLength();
|
|
|
|
|
2017-12-09 12:23:18 -05:00
|
|
|
enum AngleType type() { return _type; };
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum AngleType _type;
|
|
|
|
float _sumx;
|
|
|
|
float _sumy;
|
|
|
|
uint32_t _count;
|
|
|
|
};
|
|
|
|
#endif
|