From 1c437fec33eda09a0e06ab48ac99278a600c2fe7 Mon Sep 17 00:00:00 2001 From: Daniel Lisunkin Date: Wed, 3 Jul 2019 15:44:20 +0200 Subject: [PATCH] Fixed calculation mistake in getImpliedWind() method. --- .../sailing/domain/orc/TestORCPerformanceCurve.java | 10 +++++----- .../domain/orc/impl/ORCPerformanceCurveImpl.java | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/orc/TestORCPerformanceCurve.java b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/orc/TestORCPerformanceCurve.java index 98888a0a876..f5e1a685f19 100644 --- a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/orc/TestORCPerformanceCurve.java +++ b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/orc/TestORCPerformanceCurve.java @@ -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. diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/orc/impl/ORCPerformanceCurveImpl.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/orc/impl/ORCPerformanceCurveImpl.java index ec767735746..f293a6d9e96 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/orc/impl/ORCPerformanceCurveImpl.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/orc/impl/ORCPerformanceCurveImpl.java @@ -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;