0.2.1 AngleConvertor

This commit is contained in:
Rob Tillaart 2024-01-25 15:11:14 +01:00
parent 427b1efbbe
commit 7225a83850
8 changed files with 119 additions and 31 deletions

View File

@ -2,7 +2,7 @@
// //
// FILE: AngleConvertor.h // FILE: AngleConvertor.h
// AUTHOR: Rob Tillaart // AUTHOR: Rob Tillaart
// VERSION: 0.2.0 // VERSION: 0.2.1
// DATE: 2022-12-01 // DATE: 2022-12-01
// PURPOSE: Angle conversion class // PURPOSE: Angle conversion class
// URL: https://github.com/RobTillaart/AngleConvertor // URL: https://github.com/RobTillaart/AngleConvertor
@ -11,7 +11,7 @@
#include "Arduino.h" #include "Arduino.h"
#define ANGLECONVERTOR_LIB_VERSION (F("0.2.0")) #define ANGLECONVERTOR_LIB_VERSION (F("0.2.1"))
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
@ -33,11 +33,13 @@ public:
void setDiameterPart(double value = 0) { _v = value * (180.0 / 60.0); }; void setDiameterPart(double value = 0) { _v = value * (180.0 / 60.0); };
void setHexacontade(double value = 0) { _v = value * (180.0 / 30.0); }; void setHexacontade(double value = 0) { _v = value * (180.0 / 30.0); };
void setHourAngle(double value = 0) { _v = value * (180.0 / 12.0); }; void setHourAngle(double value = 0) { _v = value * (180.0 / 12.0); };
void setMilliRadians(double value = 0) { _v = value * (180.0 / (M_PI * 1000.0)); };
void setMilliTurn(double value = 0) { _v = value * (180.0 / 500.0); }; void setMilliTurn(double value = 0) { _v = value * (180.0 / 500.0); };
void setMinuteTime(double value = 0) { _v = value * (180.0 / 720.0); }; void setMinuteTime(double value = 0) { _v = value * (180.0 / 720.0); };
void setOctant(double value = 0) { _v = value * (180.0 / 4.0); }; void setOctant(double value = 0) { _v = value * (180.0 / 4.0); };
void setPechus(double value = 0) { _v = value * (180.0 / 90.0); }; // assumes 2° void setPechus(double value = 0) { _v = value * (180.0 / 90.0); }; // assumes 2°
void setPercent(double value = 0) { _v = value * (180.0 / 50.0); }; // equals centiTurn..
void setPoints(double value = 0) { _v = value * (180.0 / 16.0); }; void setPoints(double value = 0) { _v = value * (180.0 / 16.0); };
void setQuadrant(double value = 0) { _v = value * (180.0 / 2.0); }; void setQuadrant(double value = 0) { _v = value * (180.0 / 2.0); };
void setQuarterPoint(double value = 0) { _v = value * (180.0 / 64.0); }; void setQuarterPoint(double value = 0) { _v = value * (180.0 / 64.0); };
@ -57,11 +59,13 @@ public:
double getDiameterPart() { return _v * (60.0 / 180.0); }; double getDiameterPart() { return _v * (60.0 / 180.0); };
double getHexacontade() { return _v * (30.0 / 180.0); }; double getHexacontade() { return _v * (30.0 / 180.0); };
double getHourAngle() { return _v * (12.0 / 180.0); }; double getHourAngle() { return _v * (12.0 / 180.0); };
double getMilliRadians() { return _v * (M_PI * 1000.0 / 180.0); };
double getMilliTurn() { return _v * (500.0 / 180.0); }; double getMilliTurn() { return _v * (500.0 / 180.0); };
double getMinuteTime() { return _v * (720.0 / 180.0); }; double getMinuteTime() { return _v * (720.0 / 180.0); };
double getOctant() { return _v * (4.0 / 180.0); }; double getOctant() { return _v * (4.0 / 180.0); };
double getPechus() { return _v * (90.0 / 180.0); }; // assumes 2° double getPechus() { return _v * (90.0 / 180.0); }; // assumes 2°
double getPercent() { return _v * (50.0 / 180.0); }
double getPoints() { return _v * (16.0 / 180.0); }; double getPoints() { return _v * (16.0 / 180.0); };
double getQuadrant() { return _v * (2.0 / 180.0); }; double getQuadrant() { return _v * (2.0 / 180.0); };
double getQuarterPoint() { return _v * (64.0 / 180.0); }; double getQuarterPoint() { return _v * (64.0 / 180.0); };

View File

@ -1,4 +1,4 @@
# Change Log Angle # Change Log AngleConvertor
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this 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/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [0.2.1] - 2024-01-24
- add percent as unit
- add milliRadians as unit
- add unit tests for windrose()
## [0.2.0] - 2024-01-15 ## [0.2.0] - 2024-01-15
- Fix #4, use **degrees** as internal format to improve precision (a bit) - Fix #4, use **degrees** as internal format to improve precision (a bit)

View File

@ -27,10 +27,10 @@ can gain extra precision.
#### Formats #### Formats
| name | full circle | | name | full circle | notes |
|:----------------|--------------:| |:----------------|--------------:|:--------|
| Degrees | 360 | | Degrees | 360 |
| Radians | 2 PI | | Radians | 2 PI | 2PI is aka MU
| Gradians | 400 | | Gradians | 400 |
| AngularMil | 6400 | | AngularMil | 6400 |
| BinaryRadians | 256 | | BinaryRadians | 256 |
@ -38,10 +38,12 @@ can gain extra precision.
| DiameterPart | 120 | | DiameterPart | 120 |
| Hexacontade | 60 | | Hexacontade | 60 |
| HourAngle | 24 | | HourAngle | 24 |
| MilliRadians | 2000 PI |
| MilliTurn | 1000 | | MilliTurn | 1000 |
| MinuteTime | 1440 | | MinuteTime | 1440 |
| Octant | 8 | | Octant | 8 |
| Pechus | 180 | | Pechus | 180 |
| Percent | 100 | equals CentiTurn.
| Points | 32 | | Points | 32 |
| Quadrant | 4 | | Quadrant | 4 |
| QuarterPoint | 128 | | QuarterPoint | 128 |
@ -82,10 +84,12 @@ can gain extra precision.
- **void setDiameterPart(double value = 0)** - **void setDiameterPart(double value = 0)**
- **void setHexacontade(double value = 0)** - **void setHexacontade(double value = 0)**
- **void setHourAngle(double value = 0)** - **void setHourAngle(double value = 0)**
- **void setMilliRadians(double value = 0)**
- **void setMilliTurn(double value = 0)** - **void setMilliTurn(double value = 0)**
- **void setMinuteTime(double value = 0)** - **void setMinuteTime(double value = 0)**
- **void setOctant(double value = 0)** - **void setOctant(double value = 0)**
- **void setPechus(double value = 0)** - **void setPechus(double value = 0)**
- **void setPercent(double value = 0)**
- **void setPoints(double value = 0)** - **void setPoints(double value = 0)**
- **void setQuadrant(double value = 0)** - **void setQuadrant(double value = 0)**
- **void setQuarterPoint(double value = 0)** - **void setQuarterPoint(double value = 0)**
@ -106,10 +110,12 @@ can gain extra precision.
- **double getDiameterPart()** - **double getDiameterPart()**
- **double getHexacontade()** - **double getHexacontade()**
- **double getHourAngle()** - **double getHourAngle()**
- **double getMilliRadians()**
- **double getMilliTurn()** - **double getMilliTurn()**
- **double getMinuteTime()** - **double getMinuteTime()**
- **double getOctant()** - **double getOctant()**
- **double getPechus()** - **double getPechus()**
- **double getPercent()**
- **double getPoints()** - **double getPoints()**
- **double getQuadrant()** - **double getQuadrant()**
- **double getQuarterPoint()** - **double getQuarterPoint()**

View File

@ -16,16 +16,20 @@ AngleConvertor conv;
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
Serial.println();
Serial.println(__FILE__); Serial.println(__FILE__);
Serial.print("lib version: "); Serial.print("ANGLECONVERTOR_LIB_VERSION: ");
Serial.println(ANGLECONVERTOR_LIB_VERSION); Serial.println(ANGLECONVERTOR_LIB_VERSION);
Serial.println(); Serial.println();
// if double = 8 bytes adjust #decimals // if double = 8 bytes adjust #decimals
uint8_t decimals = 7; uint8_t decimals = 6;
if (sizeof(double) == 8) decimals = 15; if (sizeof(double) == 8) decimals = 12;
// Serial.println("UNIT \tDEGREES \tRADIANS \tUNIT");
conv.setDegrees(1.0); conv.setDegrees(1.0);
Serial.print("Degrees \t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -33,6 +37,7 @@ void setup()
Serial.println(conv.getDegrees(), decimals); Serial.println(conv.getDegrees(), decimals);
conv.setRadians(1.0); conv.setRadians(1.0);
Serial.print("Radians \t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -40,6 +45,7 @@ void setup()
Serial.println(conv.getRadians(), decimals); Serial.println(conv.getRadians(), decimals);
conv.setGradians(1.0); conv.setGradians(1.0);
Serial.print("Gradians\t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -47,6 +53,7 @@ void setup()
Serial.println(conv.getGradians(), decimals); Serial.println(conv.getGradians(), decimals);
conv.setAngularMil(1.0); conv.setAngularMil(1.0);
Serial.print("AngularMil\t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -54,6 +61,7 @@ void setup()
Serial.println(conv.getAngularMil(), decimals); Serial.println(conv.getAngularMil(), decimals);
conv.setBinaryRadians(1.0); conv.setBinaryRadians(1.0);
Serial.print("BinaryRadians\t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -61,6 +69,7 @@ void setup()
Serial.println(conv.getBinaryRadians(), decimals); Serial.println(conv.getBinaryRadians(), decimals);
conv.setCentiTurn(1.0); conv.setCentiTurn(1.0);
Serial.print("CentiTurn\t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -68,6 +77,7 @@ void setup()
Serial.println(conv.getCentiTurn(), decimals); Serial.println(conv.getCentiTurn(), decimals);
conv.setDiameterPart(1.0); conv.setDiameterPart(1.0);
Serial.print("DiameterPart\t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -75,6 +85,7 @@ void setup()
Serial.println(conv.getDiameterPart(), decimals); Serial.println(conv.getDiameterPart(), decimals);
conv.setHexacontade(1.0); conv.setHexacontade(1.0);
Serial.print("Hexacontade\t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -82,13 +93,23 @@ void setup()
Serial.println(conv.getHexacontade(), decimals); Serial.println(conv.getHexacontade(), decimals);
conv.setHourAngle(1.0); conv.setHourAngle(1.0);
Serial.print("HourAngle\t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.println(conv.getHourAngle(), decimals); Serial.println(conv.getHourAngle(), decimals);
conv.setMilliRadians(1.0);
Serial.print("MilliRadians\t");
Serial.print(conv.getDegrees(), decimals);
Serial.print("\t");
Serial.print(conv.getRadians(), decimals);
Serial.print("\t");
Serial.println(conv.getMilliRadians(), decimals);
conv.setMilliTurn(1.0); conv.setMilliTurn(1.0);
Serial.print("MilliTurn\t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -96,6 +117,7 @@ void setup()
Serial.println(conv.getMilliTurn(), decimals); Serial.println(conv.getMilliTurn(), decimals);
conv.setMinuteTime(1.0); conv.setMinuteTime(1.0);
Serial.print("MinuteTime\t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -103,6 +125,7 @@ void setup()
Serial.println(conv.getMinuteTime(), decimals); Serial.println(conv.getMinuteTime(), decimals);
conv.setOctant(1.0); conv.setOctant(1.0);
Serial.print("Octant \t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -110,13 +133,23 @@ void setup()
Serial.println(conv.getOctant(), decimals); Serial.println(conv.getOctant(), decimals);
conv.setPechus(1.0); conv.setPechus(1.0);
Serial.print("Pechus \t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.println(conv.getPechus(), decimals); Serial.println(conv.getPechus(), decimals);
conv.setPercent(1.0);
Serial.print("Percent \t");
Serial.print(conv.getDegrees(), decimals);
Serial.print("\t");
Serial.print(conv.getRadians(), decimals);
Serial.print("\t");
Serial.println(conv.getPercent(), decimals);
conv.setPoints(1.0); conv.setPoints(1.0);
Serial.print("Points \t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -124,6 +157,7 @@ void setup()
Serial.println(conv.getPoints(), decimals); Serial.println(conv.getPoints(), decimals);
conv.setQuadrant(1.0); conv.setQuadrant(1.0);
Serial.print("Quadrant\t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -131,6 +165,7 @@ void setup()
Serial.println(conv.getQuadrant(), decimals); Serial.println(conv.getQuadrant(), decimals);
conv.setQuarterPoint(1.0); conv.setQuarterPoint(1.0);
Serial.print("QuarterPoint\t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -138,6 +173,7 @@ void setup()
Serial.println(conv.getQuarterPoint(), decimals); Serial.println(conv.getQuarterPoint(), decimals);
conv.setSecondsTime(1.0); conv.setSecondsTime(1.0);
Serial.print("SecondsTime\t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -145,6 +181,7 @@ void setup()
Serial.println(conv.getSecondsTime(), decimals); Serial.println(conv.getSecondsTime(), decimals);
conv.setSextant(1.0); conv.setSextant(1.0);
Serial.print("Sextant \t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -152,6 +189,7 @@ void setup()
Serial.println(conv.getSextant(), decimals); Serial.println(conv.getSextant(), decimals);
conv.setSign(1.0); conv.setSign(1.0);
Serial.print("Sign \t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);
@ -159,6 +197,7 @@ void setup()
Serial.println(conv.getSign(), decimals); Serial.println(conv.getSign(), decimals);
conv.setTurn(1.0); conv.setTurn(1.0);
Serial.print("Turn \t");
Serial.print(conv.getDegrees(), decimals); Serial.print(conv.getDegrees(), decimals);
Serial.print("\t"); Serial.print("\t");
Serial.print(conv.getRadians(), decimals); Serial.print(conv.getRadians(), decimals);

View File

@ -17,10 +17,12 @@ setCentiTurn KEYWORD2
setDiameterPart KEYWORD2 setDiameterPart KEYWORD2
setHexacontade KEYWORD2 setHexacontade KEYWORD2
setHourAngle KEYWORD2 setHourAngle KEYWORD2
setMilliRadians KEYWORD2
setMilliTurn KEYWORD2 setMilliTurn KEYWORD2
setMinuteTime KEYWORD2 setMinuteTime KEYWORD2
setOctant KEYWORD2 setOctant KEYWORD2
setPechus KEYWORD2 setPechus KEYWORD2
setPercent KEYWORD2
setPoints KEYWORD2 setPoints KEYWORD2
setQuadrant KEYWORD2 setQuadrant KEYWORD2
setQuarterPoint KEYWORD2 setQuarterPoint KEYWORD2
@ -41,10 +43,12 @@ getCentiTurn KEYWORD2
getDiameterPart KEYWORD2 getDiameterPart KEYWORD2
getHexacontade KEYWORD2 getHexacontade KEYWORD2
getHourAngle KEYWORD2 getHourAngle KEYWORD2
getMilliRadians KEYWORD2
getMilliTurn KEYWORD2 getMilliTurn KEYWORD2
getMinuteTime KEYWORD2 getMinuteTime KEYWORD2
getOctant KEYWORD2 getOctant KEYWORD2
getPechus KEYWORD2 getPechus KEYWORD2
getPercent KEYWORD2
getPoints KEYWORD2 getPoints KEYWORD2
getQuadrant KEYWORD2 getQuadrant KEYWORD2
getQuarterPoint KEYWORD2 getQuarterPoint KEYWORD2

View File

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

View File

@ -1,5 +1,5 @@
name=AngleConvertor name=AngleConvertor
version=0.2.0 version=0.2.1
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=Library to convert between different less known angle formats. sentence=Library to convert between different less known angle formats.

View File

@ -53,64 +53,94 @@ unittest(test_conversions)
AngleConvertor conv; AngleConvertor conv;
conv.setDegrees(1.0); conv.setDegrees(1.0);
assertEqualFloat(1.0, conv. getDegrees(), 0.00001); assertEqualFloat(1.0, conv.getDegrees(), 0.00001);
conv.setRadians(1.0); conv.setRadians(1.0);
assertEqualFloat(1.0, conv. getRadians(), 0.00001); assertEqualFloat(1.0, conv.getRadians(), 0.00001);
conv.setGradians(1.0); conv.setGradians(1.0);
assertEqualFloat(1.0, conv. getGradians(), 0.00001); assertEqualFloat(1.0, conv.getGradians(), 0.00001);
conv.setAngularMil(1.0); conv.setAngularMil(1.0);
assertEqualFloat(1.0, conv. getAngularMil(), 0.00001); assertEqualFloat(1.0, conv.getAngularMil(), 0.00001);
conv.setBinaryRadians(1.0); conv.setBinaryRadians(1.0);
assertEqualFloat(1.0, conv. getBinaryRadians(), 0.00001); assertEqualFloat(1.0, conv.getBinaryRadians(), 0.00001);
conv.setCentiTurn(1.0); conv.setCentiTurn(1.0);
assertEqualFloat(1.0, conv. getCentiTurn(), 0.00001); assertEqualFloat(1.0, conv.getCentiTurn(), 0.00001);
conv.setDiameterPart(1.0); conv.setDiameterPart(1.0);
assertEqualFloat(1.0, conv. getDiameterPart(), 0.00001); assertEqualFloat(1.0, conv.getDiameterPart(), 0.00001);
conv.setHexacontade(1.0); conv.setHexacontade(1.0);
assertEqualFloat(1.0, conv. getHexacontade(), 0.00001); assertEqualFloat(1.0, conv.getHexacontade(), 0.00001);
conv.setHourAngle(1.0); conv.setHourAngle(1.0);
assertEqualFloat(1.0, conv. getHourAngle(), 0.00001); assertEqualFloat(1.0, conv.getHourAngle(), 0.00001);
conv.setMilliRadians(1.0);
assertEqualFloat(1.0, conv.getMilliRadians(), 0.00001);
conv.setMilliTurn(1.0); conv.setMilliTurn(1.0);
assertEqualFloat(1.0, conv. getMilliTurn(), 0.00001); assertEqualFloat(1.0, conv.getMilliTurn(), 0.00001);
conv.setMinuteTime(1.0); conv.setMinuteTime(1.0);
assertEqualFloat(1.0, conv. getMinuteTime(), 0.00001); assertEqualFloat(1.0, conv.getMinuteTime(), 0.00001);
conv.setOctant(1.0); conv.setOctant(1.0);
assertEqualFloat(1.0, conv. getOctant(), 0.00001); assertEqualFloat(1.0, conv.getOctant(), 0.00001);
conv.setPechus(1.0); conv.setPechus(1.0);
assertEqualFloat(1.0, conv. getPechus(), 0.00001); assertEqualFloat(1.0, conv.getPechus(), 0.00001);
conv.setPercent(1.0);
assertEqualFloat(1.0, conv.getPercent(), 0.00001);
conv.setPoints(1.0); conv.setPoints(1.0);
assertEqualFloat(1.0, conv. getPoints(), 0.00001); assertEqualFloat(1.0, conv.getPoints(), 0.00001);
conv.setQuadrant(1.0); conv.setQuadrant(1.0);
assertEqualFloat(1.0, conv. getQuadrant(), 0.00001); assertEqualFloat(1.0, conv.getQuadrant(), 0.00001);
conv.setQuarterPoint(1.0); conv.setQuarterPoint(1.0);
assertEqualFloat(1.0, conv. getQuarterPoint(), 0.00001); assertEqualFloat(1.0, conv.getQuarterPoint(), 0.00001);
conv.setSecondsTime(1.0); conv.setSecondsTime(1.0);
assertEqualFloat(1.0, conv. getSecondsTime(), 0.00001); assertEqualFloat(1.0, conv.getSecondsTime(), 0.00001);
conv.setSextant(1.0); conv.setSextant(1.0);
assertEqualFloat(1.0, conv. getSextant(), 0.00001); assertEqualFloat(1.0, conv.getSextant(), 0.00001);
conv.setSign(1.0); conv.setSign(1.0);
assertEqualFloat(1.0, conv. getSign(), 0.00001); assertEqualFloat(1.0, conv.getSign(), 0.00001);
conv.setTurn(1.0); conv.setTurn(1.0);
assertEqualFloat(1.0, conv. getTurn(), 0.00001); assertEqualFloat(1.0, conv.getTurn(), 0.00001);
}
unittest(test_wind_rose)
{
AngleConvertor conv;
assertEqual(conv.windrose( 00.0), "N");
assertEqual(conv.windrose( 22.5), "NNE");
assertEqual(conv.windrose( 45.0), "NE");
assertEqual(conv.windrose( 67.5), "ENE");
assertEqual(conv.windrose( 90.0), "E");
assertEqual(conv.windrose(112.5), "ESE");
assertEqual(conv.windrose(135.0), "SE");
assertEqual(conv.windrose(157.5), "SSE");
assertEqual(conv.windrose(180.0), "S");
assertEqual(conv.windrose(202.5), "SSW");
assertEqual(conv.windrose(225.0), "SW");
assertEqual(conv.windrose(247.5), "WSW");
assertEqual(conv.windrose(270.0), "W");
assertEqual(conv.windrose(292.5), "WNW");
assertEqual(conv.windrose(315.0), "NW");
assertEqual(conv.windrose(337.5), "NNW");
assertEqual(conv.windrose(360.0), "N");
} }