Merge remote-tracking branch 'origin/story31.2' into story31.2

This commit is contained in:
hba56
2017-05-14 15:16:18 +12:00
3 changed files with 204 additions and 43 deletions
@@ -11,6 +11,7 @@ import static org.testng.Assert.*;
*/
public class PolarsTest {
@Test
/**
* Tests if we can parse a polar data file (stored in a string), create a polar table, and calculate VMG for a variety of values.
@@ -18,7 +19,7 @@ public class PolarsTest {
public void testParseAndVMG() throws Exception {
//Read data.
Polars polars;
Polars polars = null;
try {
//Parse data file.
polars = PolarParser.parse("polars/acc_polars.csv");
@@ -27,20 +28,66 @@ public class PolarsTest {
assertTrue(false);
}
double angleEpsilon = 2;
double speedEpsilon = 2;//Are these epsilons a bit too big?
//Test 1.
//TODO make these tests actually do something when the calculateVMG function is added.
//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 = TODO;
//double vmgSpeed1 = TODO;
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, destAngle1, windSpeed1);
//double calcVMGAngle1 = calcVMG1.getKey();
//double calcVMGSpeed1 = calcVMG1.getValue();
VMG calcVMG1 = polars.calculateVMG(windAngle1, windSpeed1, destAngle1, 0, 360);
double calcVMGAngle1 = calcVMG1.getBearing();
double calcVMGSpeed1 = calcVMG1.getSpeed();
//assertEquals(vmgAngle1, calcVMGAngle1, 0.1);
//assertEquals(vmgSpeed1, calcVMGSpeed1, 0.1);
System.out.println("VMG speed = " + calcVMGSpeed1 + " , VMG angle = " + calcVMGAngle1);//TEMP DEBUG REMOVE
//assertEquals(calcVMGAngle1, vmgAngle1, angleEpsilon);
//assertEquals(calcVMGSpeed1, vmgSpeed1, speedEpsilon);
//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 = 40;//knots
double vmgAngle2 = 88;
double vmgSpeed2 = 12;
VMG calcVMG2 = polars.calculateVMG(windAngle2, windSpeed2, destAngle2, 0, 360);
double calcVMGAngle2 = calcVMG2.getBearing();
double calcVMGSpeed2 = calcVMG2.getSpeed();
System.out.println("VMG speed = " + calcVMGSpeed2 + " , VMG angle = " + calcVMGAngle2);//TEMP DEBUG REMOVE
//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);
}