Fixed calculation mistake in getImpliedWind() method.

This commit is contained in:
Daniel Lisunkin committed 2019-07-03 15:44:20 +02:00
1 parent 28a6ecfb7b
commit 1c437fec33
2 files changed
+7 -7

No files matched your search

@@ -136,11 +136,11 @@ public class TestORCPerformanceCurve {
assertEquals(17.23, performanceCurve.getImpliedWind(performanceCurve.getAllowancePerCourse(new KnotSpeedImpl(17.23))).getKnots(), accuracy);
assertEquals( 18, performanceCurve.getImpliedWind(performanceCurve.getAllowancePerCourse(new KnotSpeedImpl( 18))).getKnots(), accuracy);
assertEquals( 450, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(450).times(courseLengthNauticalMiles))).asSeconds(), accuracy);
assertEquals( 500, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(500).times(courseLengthNauticalMiles))).asSeconds(), accuracy);
assertEquals( 600, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(600).times(courseLengthNauticalMiles))).asSeconds(), accuracy);
assertEquals( 700, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(700).times(courseLengthNauticalMiles))).asSeconds(), accuracy);
assertEquals( 750, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(750).times(courseLengthNauticalMiles))).asSeconds(), accuracy);
assertEquals( 450, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(450).times(courseLengthNauticalMiles))).asSeconds() / courseLengthNauticalMiles, accuracy);
assertEquals( 500, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(500).times(courseLengthNauticalMiles))).asSeconds() / courseLengthNauticalMiles, accuracy);
assertEquals( 600, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(600).times(courseLengthNauticalMiles))).asSeconds() / courseLengthNauticalMiles, accuracy);
assertEquals( 700, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(700).times(courseLengthNauticalMiles))).asSeconds() / courseLengthNauticalMiles, accuracy);
assertEquals( 750, performanceCurve.getAllowancePerCourse(performanceCurve.getImpliedWind(Duration.ONE_SECOND.times(750).times(courseLengthNauticalMiles))).asSeconds() / courseLengthNauticalMiles, accuracy);
}
// Tests for a Implied Wind calculation for a simple predefined course. The solutions are extracted from the provided ORC TestPCS.exe application.
@@ -186,14 +186,14 @@ public class ORCPerformanceCurveImpl implements Serializable, ORCPerformanceCurv
}
// Corner cases for Allowance > Allowance(20kt) or Allowance < Allowance(6kt)
if(timePerNauticalMileInSeconds >= allowancesInSeconds[allowancesInSeconds.length - 1]) {
if(timePerNauticalMileInSeconds <= allowancesInSeconds[allowancesInSeconds.length - 1]) {
return new KnotSpeedImpl(6);
} else if (timePerNauticalMileInSeconds >= allowancesInSeconds[0]) {
return new KnotSpeedImpl(20);
}
int i = 0;
while(i < allowancesInSeconds.length && timePerNauticalMileInSeconds >= allowancesInSeconds[i]) {
while(i < allowancesInSeconds.length && timePerNauticalMileInSeconds <= allowancesInSeconds[i]) {
i += 1;
}
i -= 1;