Implemented algorithm for checking if boat passes through a mark.

Mark rounding works for whole course (WITH BUGS)
Still some gate logic to work out.
Moved gate function to GeoUtil class

tags: #story[1124] #pair[hyi25, wmu16]
This commit is contained in:
William Muir
2017-08-07 17:28:12 +12:00
parent 7f0329dda6
commit 4375b73257
5 changed files with 78 additions and 7 deletions
@@ -9,9 +9,11 @@ import javafx.geometry.Point2D;
import org.junit.Before;
import org.junit.Test;
import seng302.model.GeoPoint;
import seng302.model.mark.CompoundMark;
import seng302.utilities.GeoUtility;
/**
* http://www.geoplaner.com/ For plotting geo points for visualisation
* To test methods in GeoUtility.
* Use this site to calculate distances
* https://rechneronline.de/geo-coordinates/#distance
@@ -150,4 +152,22 @@ public class GeoUtilityTest {
assertFalse(GeoUtility.isPointInTriangle(v1, v2, v3, p2));
}
@Test
public void testCheckCrossedGate() {
GeoPoint mark1 = new GeoPoint(37.40937, -122.62233);
GeoPoint mark2 = new GeoPoint(37.40938, -122.62154);
GeoPoint location1 = new GeoPoint(37.40964, -122.62196);
GeoPoint location2 = new GeoPoint(37.40910, -122.62189);
GeoPoint location3 = new GeoPoint(37.40949, -122.62202);
GeoPoint location4 = new GeoPoint(34.40955, -122.62176);
GeoPoint location5 = new GeoPoint(37.40927, -122.62152);
GeoPoint location6 = new GeoPoint(34.40933, -122.62163);
assertTrue(GeoUtility.checkCrossedLine(mark1, mark2, location1, location2));
assertFalse(GeoUtility.checkCrossedLine(mark1, mark2, location4, location3));
assertFalse(GeoUtility.checkCrossedLine(mark1, mark2, location1, location3));
assertFalse(GeoUtility.checkCrossedLine(mark1, mark2, location5, location6));
}
}