Mock.Polars. addEstimate also builds up a unique list of angles from the data file, instead of dynamically generating that when calculating a VMG.
addEstimate also adds estimates with negative angles (e.g., 45deg+windSpeed+boatSpeed, and -45deg+windSpeed+boatSpeed).
calculateVMG now accepts an upper and lower bounds to the allowed VMG bearing it returns - this way you can get VMGs only within a certain angle interval (e.g., [16, 99] degrees).
Also fixed some bugs in calculateVMG where it wasn't actually using the angles and such correctly.
Improved the test case slightly, but still need to calculate correct values by hand.
#story[873]
//We also add the same values with a negative angle, as the data file contains data for 0-180 degrees, but we also need 180-360 degrees. This is because it may turn out that going 5 degrees into the wind gives us, say, 9knots, but -5 into the wind may give us 10knots, towards our destination.
//Currently a fairly simple implementation where we find the wind speed that is less than or equal to the current wind speed (the lower bound), and then find the specific angle (with no interpolation) that gives the best VMG.
//Currently a fairly simple implementation where we find the wind speed that is less than or equal to the current wind speed (the lower bound), and then find the specific angle (with no interpolation) that gives the best VMG.
//TODO we need to add interpolation between angles for a given wind speed (e.g., we have 0 deg, 30 deg, but the optimal bearing may be 17.3 degrees).
//TODO we should also interpolate between wind speeds (e.g., we have 12kn and 16kn, but if the wind speed is actually 15.999kn, then we should interpolate to get a more accurate final value).
doublepolarWindSpeed=0;
doublepolarWindSpeed=0;
@ -60,41 +93,65 @@ public class Polars {
}
}
}
}
//We create a list of wind angles because we need (speed, angle) pairs to look into the map.
//System.out.println("selecting " + polarAngle + " degrees from wind dir, and " + polarWindSpeed + "knots wind speed.");//TEMP DEBUG REMOVE
//We need to check that the map contains this (speed, angle) pair because some of the datafile entries have different angles in the same column (e.g., (16kn, 45 deg) and (20kn, 43 deg), but there is no (20kn, 45 deg).
if(this.polarValues.containsKey(key)){
if(this.polarValues.containsKey(key)){
//This is the velocity from the polar table at this wind speed/angle.
//This is the velocity from the polar table at this wind speed/angle.