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

57 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-11-02 15:25:44 -04:00
// VERSION: 0.1.2
2022-01-28 15:42:11 -05:00
// PURPOSE: Arduino library for ellipse maths
// URL: https://github.com/RobTillaart/ellipse
//
#include "Arduino.h"
2022-11-02 15:25:44 -04:00
#define ELLIPSE_LIB_VERSION (F("0.1.2"))
2022-01-28 15:42:11 -05:00
class ellipse
{
public:
2022-11-02 15:25:44 -04:00
ellipse(float a, float b); // a >= b
2022-01-28 15:42:11 -05:00
float area();
2022-11-02 15:25:44 -04:00
float circumference(); // good algorithm,
float perimeter_ref(); // pretty slow but very good over long range
2022-01-28 15:42:11 -05:00
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-11-02 15:25:44 -04:00
2022-07-25 03:40:13 -04:00
// convenience functions.
bool isCircle(float epsilon = 0.0);
2022-11-02 15:25:44 -04:00
bool isFlat(); // factor 4 ==> < 15°
2022-01-28 15:42:11 -05:00
2022-11-02 15:25:44 -04:00
void setA(float a); // uses abs(a)
void setB(float b); // uses abs(b)
float getA();
float getB();
2022-01-28 15:42:11 -05:00
float getC();
2022-11-02 15:25:44 -04:00
float getLongRadius();
float getShortRadius();
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 --