Merge branch 'master' into story68

-updated port and starboard boat checks
-added gps method to check if on correct side of a line
-updated pos check method to make boats round marks with the new tech

# Conflicts:
#	racevisionGame/src/main/java/mock/app/ConnectionAcceptor.java
#	racevisionGame/src/main/java/mock/app/Event.java
#	racevisionGame/src/main/java/mock/model/commandFactory/TackGybeCommand.java
#	racevisionGame/src/main/java/mock/model/commandFactory/VMGCommand.java
This commit is contained in:
hba56
2017-08-12 03:26:28 +12:00
parent 499a409d4f
commit d70a711a3d
7 changed files with 87 additions and 34 deletions
@@ -170,6 +170,46 @@ public class GPSCoordinate {
}
/**
* Checks to see if a point passes or lands on a line
* @param linePointA first point for a line
* @param linePointB second point for a line
* @param point point to check
* @param directionBearing direction of the correct side of line
* @return true if on the correct side
*/
public static boolean passesLine(GPSCoordinate linePointA, GPSCoordinate linePointB, GPSCoordinate point, Bearing directionBearing) {
double d = lineCheck(linePointA, linePointB, point);//this gives a number < 0 for one side and > 0 for an other
//to find if the side is the correct one
//compare with point that is known on the correct side
GPSCoordinate pointForComparison = GPSCoordinate.calculateNewPosition(linePointA,
250, Azimuth.fromDegrees(directionBearing.degrees()));
double d2 = lineCheck(linePointA, linePointB, pointForComparison);
return (d > 0 && d2 > 0) || (d < 0 && d2 < 0) || d == 0;
}
/**
* returns a double that is positive or negative based on which
* side of the line it is on. returns 0 if it is on the line
* @param linePointA first point to make up the line
* @param linePointB second point to make up the line
* @param point the point to check
* @return greater than 0 for one side, less than 0 for another
*/
private static double lineCheck(GPSCoordinate linePointA, GPSCoordinate linePointB, GPSCoordinate point) {
double linePointALat = linePointA.getLatitude();
double linePointALon = linePointA.getLongitude();
double linePointBLat = linePointB.getLatitude();
double linePointBLon = linePointB.getLongitude();
double pointLat = point.getLatitude();
double pointLon = point.getLongitude();
double d1 = (pointLat - linePointALat) * (linePointBLon - linePointALon);
double d2 = (pointLon - linePointALon) * (linePointBLat - linePointALat);
return d1 - d2; //this gives a number < 0 for one side and > 0 for an other
}
/**