0.1.3 ellipse

This commit is contained in:
Rob Tillaart 2023-10-25 20:42:40 +02:00
parent f612c4451e
commit a5482778d7
8 changed files with 65 additions and 25 deletions

View File

@ -2,8 +2,11 @@
[![Arduino CI](https://github.com/RobTillaart/DS1821/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/DS1821/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/DS1821/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/DS1821/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/DS1821/actions/workflows/jsoncheck.yml)
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/DS1821.svg)](https://github.com/RobTillaart/DS1821/issues)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/DS1821/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/DS1821.svg?maxAge=3600)](https://github.com/RobTillaart/DS1821/releases)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/DS1821.svg)](https://registry.platformio.org/libraries/robtillaart/DS1821)
# DS1821

View File

@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.1.2] - 2023-10-25
- update readme.md
- update keywords.txt
## [0.1.2] - 2022-11-02
- add changelog.md
- add rp2040 to build-CI
@ -13,7 +18,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- refactor code
- add getLongRadius() and getShortRadius()
## [0.1.1] - 2022-07-24
- add angle() + example
- add isCircle(), isFlat()

View File

@ -2,8 +2,11 @@
[![Arduino CI](https://github.com/RobTillaart/ellipse/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/ellipse/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/ellipse/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/ellipse/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/ellipse/actions/workflows/jsoncheck.yml)
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/ellipse.svg)](https://github.com/RobTillaart/ellipse/issues)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/ellipse/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/ellipse.svg?maxAge=3600)](https://github.com/RobTillaart/ellipse/releases)
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/ellipse.svg)](https://registry.platformio.org/libraries/robtillaart/ellipse)
# ellipse
@ -22,6 +25,10 @@ Trigger was a video of Dr. Matt Parker.
## Interface
```cpp
#include "ellipse.h"
```
- **ellipse(float a, float b)** constructor, a >= b
- **float area()** returns the area of the ellipse.
- **float circumference()** good algorithm (= Ramanujan 1).
@ -36,6 +43,8 @@ This is an indication of flatness of the ellipse. 0 is a circle 1 is flat line.
#### Perimeter algorithms
Perimeter == circumference
- **float perimeter_ref()** slower but best known algorithm (Ramanujan 2)
- **float perimeter_Keppler()** good and fast algorithm for eccentricity between 1 and 2.
- **float perimeter_Ramanujan1()** good algorithm.
@ -44,7 +53,7 @@ This is an indication of flatness of the ellipse. 0 is a circle 1 is flat line.
See performance example for differences in timing.
#### Misc
#### Convenience functions
- **bool isCircle(float epsilon = 0.0)** | a - b | < eps.
- **bool isFlat()** true if a > 4b, where a = longest radius.
@ -63,10 +72,30 @@ See examples.
## Future
#### Must
- improve documentation
- refer Wikipedia.
#### Should
- make constructor symmetric (a < b or a > b ==> all possible.
- make other code symmetric.
#### Could
- replace float by double?
- additional functions
- Bresenham to draw ellipse?
- documentation
- refer Wikipedia.
#### Wont
## Support
If you appreciate my libraries, you can support the development and maintenance.
Improve the quality of the libraries by providing issues and Pull Requests, or
donate through PayPal or GitHub sponsors.
Thank you,

View File

@ -2,12 +2,10 @@
// FILE: ellipse.cpp
// AUTHOR: Rob Tillaart
// DATE: 2021-10-31
// VERSION: 0.1.2
// VERSION: 0.1.3
// PURPOSE: Arduino library for ellipse maths
// URL: https://github.com/RobTillaart/ellipse
// TRIGGER: https://www.youtube.com/watch?v=5nW3nJhBHL0
//
// HISTORY: see changelog.md
#include "ellipse.h"
@ -21,7 +19,7 @@ ellipse::ellipse(float a, float b)
//////////////////////////////////////////////////////////////////
//
//
// unknown - see youtube link.
// p = 2 * PI * sqrt((a*a + b*b)/2);
//
@ -39,7 +37,7 @@ float ellipse::perimeter_ref()
float ellipse::perimeter_Keppler()
{
// Keppler
// Keppler
float p = 2 * PI * (_a + _b) / 2; // very fast for a ~ b
return p;
}
@ -51,7 +49,7 @@ float ellipse::perimeter_Ramanujan1()
// float p = PI * (3 * (_a + _b) - sqrt((3 * _a +_b)*(_a + 3 * _b)));
float a3 = 3 * _a;
float b3 = 3 * _b;
float p = PI * (a3 + b3 - sqrt( (a3 + _b)*(_a + b3)));
float p = PI * (a3 + b3 - sqrt( (a3 + _b)*(_a + b3)));
// one float operation less (~7% faster)
return p;
}
@ -108,7 +106,7 @@ void ellipse::setA(float a)
void ellipse::setB(float b)
{
_b = abs(b);
_b = abs(b);
};
@ -153,5 +151,5 @@ float ellipse::angle()
}
// -- END OF FILE --
// -- END OF FILE --

View File

@ -3,23 +3,23 @@
// FILE: ellipse.h
// AUTHOR: Rob Tillaart
// DATE: 2021-10-31
// VERSION: 0.1.2
// VERSION: 0.1.3
// PURPOSE: Arduino library for ellipse maths
// URL: https://github.com/RobTillaart/ellipse
//
#include "Arduino.h"
#define ELLIPSE_LIB_VERSION (F("0.1.2"))
#define ELLIPSE_LIB_VERSION (F("0.1.3"))
class ellipse
{
public:
ellipse(float a, float b); // a >= b
ellipse(float a, float b); // a >= b
float area();
float circumference(); // good algorithm,
float circumference(); // good algorithm,
float perimeter_ref(); // pretty slow but very good over long range
float perimeter_Keppler();
float perimeter_Ramanujan1();
@ -30,7 +30,7 @@ public:
// convenience functions.
bool isCircle(float epsilon = 0.0);
bool isFlat(); // factor 4 ==> < 15°
bool isFlat(); // factor 4 ==> < 15°
void setA(float a); // uses abs(a)
void setB(float b); // uses abs(b)
@ -51,6 +51,6 @@ private:
};
// -- END OF FILE --
// -- END OF FILE --

View File

@ -5,25 +5,31 @@ ellipse KEYWORD1
# Methods and Functions (KEYWORD2)
perimeter KEYWORD2
area KEYWORD2
circumference KEYWORD2
perimeter_ref KEYWORD2
eccentricity KEYWORD2
perimeter_ref KEYWORD2
perimeter_Keppler KEYWORD2
perimeter_Ramanujan1 KEYWORD2
perimeter_Ramanujan2 KEYWORD2
eccentricity KEYWORD2
isCircle KEYWORD2
isFlat KEYWORD2
setA KEYWORD2
setB KEYWORD2
getA KEYWORD2
getB KEYWORD2
getC KEYWORD2
getLongRadius KEYWORD2
getShortRadius KEYWORD2
angle KEYWORD2
# Constants (LITERAL1)
FLE_LIB_VERSION LITERAL1
ELLIPSE_LIB_VERSION LITERAL1

View File

@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/ellipse.git"
},
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",
"frameworks": "*",
"platforms": "*"

View File

@ -1,5 +1,5 @@
name=ellipse
version=0.1.2
version=0.1.3
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for ellipse class