mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-19 16:46:11 -04:00
0.1.2 ellipse
This commit is contained in:
parent
6e0708dbcc
commit
f7ee3db64c
@ -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:
|
compile:
|
||||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||||
platforms:
|
platforms:
|
||||||
@ -9,3 +24,5 @@ compile:
|
|||||||
- esp32
|
- esp32
|
||||||
# - esp8266
|
# - esp8266
|
||||||
# - mega2560
|
# - mega2560
|
||||||
|
- rpipico
|
||||||
|
|
||||||
|
23
libraries/ellipse/CHANGELOG.md
Normal file
23
libraries/ellipse/CHANGELOG.md
Normal 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
|
@ -67,9 +67,6 @@ See examples.
|
|||||||
- make other code symmetric.
|
- make other code symmetric.
|
||||||
- additional functions
|
- additional functions
|
||||||
- Bresenham to draw ellipse?
|
- Bresenham to draw ellipse?
|
||||||
- **float getLongRadius()**
|
|
||||||
- **float getShortRadius()**
|
|
||||||
- move all code to .cpp
|
|
||||||
- documentation
|
- documentation
|
||||||
- refer Wikipedia.
|
- refer Wikipedia.
|
||||||
|
|
||||||
|
@ -2,16 +2,12 @@
|
|||||||
// FILE: ellipse.cpp
|
// FILE: ellipse.cpp
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// DATE: 2021-10-31
|
// DATE: 2021-10-31
|
||||||
// VERSION: 0.1.1
|
// VERSION: 0.1.2
|
||||||
// PURPOSE: Arduino library for ellipse maths
|
// PURPOSE: Arduino library for ellipse maths
|
||||||
// URL: https://github.com/RobTillaart/ellipse
|
// URL: https://github.com/RobTillaart/ellipse
|
||||||
// TRIGGER: https://www.youtube.com/watch?v=5nW3nJhBHL0
|
// TRIGGER: https://www.youtube.com/watch?v=5nW3nJhBHL0
|
||||||
//
|
//
|
||||||
// HISTORY:
|
// HISTORY: see changelog.md
|
||||||
// 0.1.0 2021-10-31 initial version
|
|
||||||
// 0.1.1 2022-07- add angle() + example
|
|
||||||
// add isCircle(), isFlat()
|
|
||||||
// update readme.md
|
|
||||||
|
|
||||||
|
|
||||||
#include "ellipse.h"
|
#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 ellipse::getC()
|
||||||
{
|
{
|
||||||
float e = eccentricity();
|
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 ellipse::angle()
|
||||||
{
|
{
|
||||||
float c = (_b < _a) ? _b/_a : _a/_b;
|
float c = (_b < _a) ? _b/_a : _a/_b;
|
||||||
return acos(c) * (180 / PI);
|
return acos(c) * (180 / PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// -- END OF FILE --
|
// -- END OF FILE --
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// FILE: ellipse.h
|
// FILE: ellipse.h
|
||||||
// AUTHOR: Rob Tillaart
|
// AUTHOR: Rob Tillaart
|
||||||
// DATE: 2021-10-31
|
// DATE: 2021-10-31
|
||||||
// VERSION: 0.1.1
|
// VERSION: 0.1.2
|
||||||
// PURPOSE: Arduino library for ellipse maths
|
// PURPOSE: Arduino library for ellipse maths
|
||||||
// URL: https://github.com/RobTillaart/ellipse
|
// URL: https://github.com/RobTillaart/ellipse
|
||||||
//
|
//
|
||||||
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
|
|
||||||
#define ELLIPSE_LIB_VERSION (F("0.1.1"))
|
#define ELLIPSE_LIB_VERSION (F("0.1.2"))
|
||||||
|
|
||||||
|
|
||||||
class ellipse
|
class ellipse
|
||||||
@ -26,16 +26,21 @@ public:
|
|||||||
float perimeter_Ramanujan2();
|
float perimeter_Ramanujan2();
|
||||||
|
|
||||||
float eccentricity();
|
float eccentricity();
|
||||||
|
|
||||||
|
|
||||||
// convenience functions.
|
// convenience functions.
|
||||||
bool isCircle(float epsilon = 0.0);
|
bool isCircle(float epsilon = 0.0);
|
||||||
bool isFlat(); // factor 4 ==> < 15°
|
bool isFlat(); // factor 4 ==> < 15°
|
||||||
|
|
||||||
void setA(float a) { _a = abs(a); };
|
void setA(float a); // uses abs(a)
|
||||||
void setB(float b) { _b = abs(b); };
|
void setB(float b); // uses abs(b)
|
||||||
float getA() { return _a; };
|
float getA();
|
||||||
float getB() { return _b; };
|
float getB();
|
||||||
float getC();
|
float getC();
|
||||||
|
|
||||||
|
float getLongRadius();
|
||||||
|
float getShortRadius();
|
||||||
|
|
||||||
// experimental
|
// experimental
|
||||||
// returns the angle if the ellipse was the shadow of a circle.
|
// returns the angle if the ellipse was the shadow of a circle.
|
||||||
float angle();
|
float angle();
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/RobTillaart/ellipse.git"
|
"url": "https://github.com/RobTillaart/ellipse.git"
|
||||||
},
|
},
|
||||||
"version": "0.1.1",
|
"version": "0.1.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"frameworks": "*",
|
"frameworks": "*",
|
||||||
"platforms": "*"
|
"platforms": "*"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=ellipse
|
name=ellipse
|
||||||
version=0.1.1
|
version=0.1.2
|
||||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||||
sentence=Arduino library for ellipse class
|
sentence=Arduino library for ellipse class
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
unittest_setup()
|
unittest_setup()
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "ELLIPSE_LIB_VERSION: %s\n", (char*) ELLIPSE_LIB_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -39,8 +40,6 @@ unittest_teardown()
|
|||||||
|
|
||||||
unittest(test_constructor)
|
unittest(test_constructor)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ELLIPSE_LIB_VERSION: %s\n", (char*) ELLIPSE_LIB_VERSION);
|
|
||||||
|
|
||||||
ellipse E(1.0, 1.0);
|
ellipse E(1.0, 1.0);
|
||||||
fprintf(stderr, "%03.8f\n", E.getA());
|
fprintf(stderr, "%03.8f\n", E.getA());
|
||||||
fprintf(stderr, "%03.8f\n", E.getB());
|
fprintf(stderr, "%03.8f\n", E.getB());
|
||||||
|
Loading…
Reference in New Issue
Block a user