GY-63_MS5611/libraries/ellipse/ellipse.h

52 lines
1.0 KiB
C
Raw Normal View History

2022-01-28 15:42:11 -05:00
#pragma once
//
// FILE: ellipse.h
// AUTHOR: Rob Tillaart
// DATE: 2021-10-31
2022-07-25 03:40:13 -04:00
// VERSION: 0.1.1
2022-01-28 15:42:11 -05:00
// PURPOSE: Arduino library for ellipse maths
// URL: https://github.com/RobTillaart/ellipse
//
#include "Arduino.h"
2022-07-25 03:40:13 -04:00
#define ELLIPSE_LIB_VERSION (F("0.1.1"))
2022-01-28 15:42:11 -05:00
class ellipse
{
public:
ellipse(float a, float b); // a >= b
float area();
float circumference(); // good algorithm,
float perimeter_ref(); // pretty slow but very good over long range
float perimeter_Keppler();
float perimeter_Ramanujan1();
float perimeter_Ramanujan2();
2022-07-25 03:40:13 -04:00
2022-01-28 15:42:11 -05:00
float eccentricity();
2022-07-25 03:40:13 -04:00
// convenience functions.
bool isCircle(float epsilon = 0.0);
bool isFlat(); // factor 4 ==> < 15°
2022-01-28 15:42:11 -05:00
void setA(float a) { _a = abs(a); };
void setB(float b) { _b = abs(b); };
float getA() { return _a; };
float getB() { return _b; };
float getC();
2022-07-25 03:40:13 -04:00
// experimental
// returns the angle if the ellipse was the shadow of a circle.
float angle();
2022-01-28 15:42:11 -05:00
private:
float _a;
float _b;
};
// -- END OF FILE --