From a5482778d7d56e549397df1d76214fdaae327801 Mon Sep 17 00:00:00 2001 From: Rob Tillaart Date: Wed, 25 Oct 2023 20:42:40 +0200 Subject: [PATCH] 0.1.3 ellipse --- libraries/DS1821/README.md | 3 +++ libraries/ellipse/CHANGELOG.md | 6 ++++- libraries/ellipse/README.md | 35 +++++++++++++++++++++++++--- libraries/ellipse/ellipse.cpp | 14 +++++------ libraries/ellipse/ellipse.h | 14 +++++------ libraries/ellipse/keywords.txt | 14 +++++++---- libraries/ellipse/library.json | 2 +- libraries/ellipse/library.properties | 2 +- 8 files changed, 65 insertions(+), 25 deletions(-) diff --git a/libraries/DS1821/README.md b/libraries/DS1821/README.md index 6f562cb6..95a2ebda 100644 --- a/libraries/DS1821/README.md +++ b/libraries/DS1821/README.md @@ -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 diff --git a/libraries/ellipse/CHANGELOG.md b/libraries/ellipse/CHANGELOG.md index 1b8ab819..ceadc16d 100644 --- a/libraries/ellipse/CHANGELOG.md +++ b/libraries/ellipse/CHANGELOG.md @@ -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() diff --git a/libraries/ellipse/README.md b/libraries/ellipse/README.md index d2168ac0..87a5fba3 100644 --- a/libraries/ellipse/README.md +++ b/libraries/ellipse/README.md @@ -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, diff --git a/libraries/ellipse/ellipse.cpp b/libraries/ellipse/ellipse.cpp index dedbc407..ccf10c72 100644 --- a/libraries/ellipse/ellipse.cpp +++ b/libraries/ellipse/ellipse.cpp @@ -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 -- diff --git a/libraries/ellipse/ellipse.h b/libraries/ellipse/ellipse.h index 82e5f027..20073ccd 100644 --- a/libraries/ellipse/ellipse.h +++ b/libraries/ellipse/ellipse.h @@ -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 -- diff --git a/libraries/ellipse/keywords.txt b/libraries/ellipse/keywords.txt index f5ab15cf..d2caec47 100644 --- a/libraries/ellipse/keywords.txt +++ b/libraries/ellipse/keywords.txt @@ -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 diff --git a/libraries/ellipse/library.json b/libraries/ellipse/library.json index 245e6597..992e599d 100644 --- a/libraries/ellipse/library.json +++ b/libraries/ellipse/library.json @@ -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": "*" diff --git a/libraries/ellipse/library.properties b/libraries/ellipse/library.properties index 82ec3a93..285db0d2 100644 --- a/libraries/ellipse/library.properties +++ b/libraries/ellipse/library.properties @@ -1,5 +1,5 @@ name=ellipse -version=0.1.2 +version=0.1.3 author=Rob Tillaart maintainer=Rob Tillaart sentence=Arduino library for ellipse class