Mock.Polars:

Fixed a bug where duplicate estimates could be added to the Polar table (this happened when the angle was 0, so the "negative" angle became 360, which is equivalent).
Now has a list of angle values for each wind speed, rather than checking if Pair<WindSpeed, WindAngle> exists in the map.
calculateVMG now uses linear interpolation between two adjacent angles (e.g., if data file contains angles 0, 30, 45, etc.. it can interpolate and find an optimal VMG angle between those, for example, 17 degrees).
Added a third test for when we provide a wind speed which is lower than any wind speed values in the Polars table. Still need to actually calculate correct VMG values by hand.

#story[873]
This commit is contained in:
fjc40
2017-05-14 01:12:36 +12:00
parent 6f9249e238
commit 2dc17a688f
2 changed files with 133 additions and 54 deletions
@@ -34,10 +34,11 @@ public class PolarsTest {
double speedEpsilon = 2;//Are these epsilons a bit too big?
//Test 1.
//This test has a wind speed that is between two values from the table (12kn, 16kn, this is 15.9kn).
double windAngle1 = 31.5;
double destAngle1 = 65.32;
double windSpeed1 = 15;//knots
double vmgAngle1 = 88;
double windSpeed1 = 15.9;//knots
double vmgAngle1 = 88; //TODO the expected results need to be calculated and placed here.
double vmgSpeed1 = 12;
VMG calcVMG1 = polars.calculateVMG(windAngle1, windSpeed1, destAngle1, 0, 360);
@@ -52,9 +53,10 @@ public class PolarsTest {
//Test 2.
//This test has a wind speed much larger than any in the table (max from table is 30kn, this is 40kn).
double windAngle2 = 200;
double destAngle2 = 35;
double windSpeed2 = 20;//knots
double windSpeed2 = 40;//knots
double vmgAngle2 = 88;
double vmgSpeed2 = 12;
@@ -68,6 +70,25 @@ public class PolarsTest {
//assertEquals(calcVMGAngle2, vmgAngle2, angleEpsilon);
//assertEquals(calcVMGSpeed2, vmgSpeed2, speedEpsilon);
//Test 3.
//This test has a wind speed lower than any non-zero values from the table (table has 0kn, 4kn, this is 2kn).
double windAngle3 = 345;
double destAngle3 = 199;
double windSpeed3 = 2;//knots
double vmgAngle3 = 88;
double vmgSpeed3 = 12;
VMG calcVMG3 = polars.calculateVMG(windAngle3, windSpeed3, destAngle3, 0, 360);
double calcVMGAngle3 = calcVMG3.getBearing();
double calcVMGSpeed3 = calcVMG3.getSpeed();
System.out.println("VMG speed = " + calcVMGSpeed3 + " , VMG angle = " + calcVMGAngle3);//TEMP DEBUG REMOVE
//assertEquals(calcVMGAngle3, vmgAngle3, angleEpsilon);
//assertEquals(calcVMGSpeed3, vmgSpeed3, speedEpsilon);
}
}