@@ -54,6 +54,9 @@ public class Angle implements Comparable<Angle> {
|
||||
return this.degrees;
|
||||
}
|
||||
|
||||
public void setDegrees(double degrees) {
|
||||
this.degrees = degrees;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of this Angle object, in radians.
|
||||
|
||||
@@ -589,9 +589,22 @@ public class Race implements Runnable {
|
||||
VMG newVMG = this.calculateVMG(boat, bearingBounds);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//If the new vmg improves velocity, use it.
|
||||
if (improvesVelocity(boat, newVMG)) {
|
||||
boat.setVMG(newVMG);
|
||||
}else if (!GPSCoordinate.isInsideBoundary(boat.getCurrentPosition(), boundary)){
|
||||
//checks to see if the new vmg sends the boat out of bounds and if so mirrors its direction in the wind
|
||||
Azimuth azimuth = Azimuth.fromBearing(boat.getBearing());
|
||||
GPSCoordinate test = GPSCoordinate.calculateNewPosition(boat.getCurrentPosition(),
|
||||
(100.0 / Constants.NMToMetersConversion), azimuth);
|
||||
double currDegrees = newVMG.getBearing().degrees();
|
||||
double windDirectionDegrees = this.windDirection.degrees();
|
||||
double tempHeading = (currDegrees - windDirectionDegrees +90)%360;
|
||||
newVMG.getBearing().setDegrees(tempHeading);
|
||||
boat.setVMG(newVMG);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user