0.1.2 ellipse

This commit is contained in:
rob tillaart 2022-11-02 20:25:44 +01:00
parent 6e0708dbcc
commit f7ee3db64c
8 changed files with 106 additions and 30 deletions

View File

@ -1,3 +1,18 @@
platforms:
rpipico:
board: rp2040:rp2040:rpipico
package: rp2040:rp2040
gcc:
features:
defines:
- ARDUINO_ARCH_RP2040
warnings:
flags:
packages:
rp2040:rp2040:
url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json
compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
@ -9,3 +24,5 @@ compile:
- esp32
# - esp8266
# - mega2560
- rpipico

View File

@ -0,0 +1,23 @@
# Change Log ellipse
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.1.2] - 2022-11-02
- add changelog.md
- add rp2040 to build-CI
- update readme.md
- refactor code
- add getLongRadius() and getShortRadius()
## [0.1.1] - 2022-07-24
- add angle() + example
- add isCircle(), isFlat()
- update readme.md
## [0.1.0] - 2021-10-31
- initial version

View File

@ -67,9 +67,6 @@ See examples.
- make other code symmetric.
- additional functions
- Bresenham to draw ellipse?
- **float getLongRadius()**
- **float getShortRadius()**
- move all code to .cpp
- documentation
- refer Wikipedia.

View File

@ -2,16 +2,12 @@
// FILE: ellipse.cpp
// AUTHOR: Rob Tillaart
// DATE: 2021-10-31
// VERSION: 0.1.1
// VERSION: 0.1.2
// PURPOSE: Arduino library for ellipse maths
// URL: https://github.com/RobTillaart/ellipse
// TRIGGER: https://www.youtube.com/watch?v=5nW3nJhBHL0
//
// HISTORY:
// 0.1.0 2021-10-31 initial version
// 0.1.1 2022-07- add angle() + example
// add isCircle(), isFlat()
// update readme.md
// HISTORY: see changelog.md
#include "ellipse.h"
@ -104,6 +100,30 @@ bool ellipse::isFlat()
}
void ellipse::setA(float a)
{
_a = abs(a);
}
void ellipse::setB(float b)
{
_b = abs(b);
};
float ellipse::getA()
{
return _a;
}
float ellipse::getB()
{
return _b;
}
float ellipse::getC()
{
float e = eccentricity();
@ -112,11 +132,26 @@ float ellipse::getC()
}
float ellipse::getLongRadius()
{
if (_a >= _b) return _a;
return _b;
}
float ellipse::getShortRadius()
{
if (_a >= _b) return _b;
return _a;
}
float ellipse::angle()
{
float c = (_b < _a) ? _b/_a : _a/_b;
return acos(c) * (180 / PI);
}
// -- END OF FILE --

View File

@ -3,7 +3,7 @@
// FILE: ellipse.h
// AUTHOR: Rob Tillaart
// DATE: 2021-10-31
// VERSION: 0.1.1
// VERSION: 0.1.2
// PURPOSE: Arduino library for ellipse maths
// URL: https://github.com/RobTillaart/ellipse
//
@ -11,7 +11,7 @@
#include "Arduino.h"
#define ELLIPSE_LIB_VERSION (F("0.1.1"))
#define ELLIPSE_LIB_VERSION (F("0.1.2"))
class ellipse
@ -26,16 +26,21 @@ public:
float perimeter_Ramanujan2();
float eccentricity();
// convenience functions.
bool isCircle(float epsilon = 0.0);
bool isFlat(); // factor 4 ==> < 15°
void setA(float a) { _a = abs(a); };
void setB(float b) { _b = abs(b); };
float getA() { return _a; };
float getB() { return _b; };
void setA(float a); // uses abs(a)
void setB(float b); // uses abs(b)
float getA();
float getB();
float getC();
float getLongRadius();
float getShortRadius();
// experimental
// returns the angle if the ellipse was the shadow of a circle.
float angle();

View File

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

View File

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

View File

@ -29,6 +29,7 @@
unittest_setup()
{
fprintf(stderr, "ELLIPSE_LIB_VERSION: %s\n", (char*) ELLIPSE_LIB_VERSION);
}
@ -39,8 +40,6 @@ unittest_teardown()
unittest(test_constructor)
{
fprintf(stderr, "ELLIPSE_LIB_VERSION: %s\n", (char*) ELLIPSE_LIB_VERSION);
ellipse E(1.0, 1.0);
fprintf(stderr, "%03.8f\n", E.getA());
fprintf(stderr, "%03.8f\n", E.getB());