|
|
|
|
@ -6,12 +6,17 @@ import mock.model.VMG;
|
|
|
|
|
import shared.model.Bearing;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Created by David on 2/08/2017.
|
|
|
|
|
* Command class for tacking and gybing
|
|
|
|
|
*/
|
|
|
|
|
public class TackGybeCommand implements Command {
|
|
|
|
|
private MockRace race;
|
|
|
|
|
private MockBoat boat;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor for class
|
|
|
|
|
* @param race mock race
|
|
|
|
|
* @param boat mock boat to update
|
|
|
|
|
*/
|
|
|
|
|
public TackGybeCommand(MockRace race, MockBoat boat) {
|
|
|
|
|
this.race = race;
|
|
|
|
|
this.boat = boat;
|
|
|
|
|
@ -39,6 +44,12 @@ public class TackGybeCommand implements Command {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Method to calculate smallest angle between 2 angles
|
|
|
|
|
* @param degreeA first angle degree
|
|
|
|
|
* @param degreeB second angle degree
|
|
|
|
|
* @return the calculated smallest angle
|
|
|
|
|
*/
|
|
|
|
|
public double calcDistance(double degreeA, double degreeB){
|
|
|
|
|
double phi = Math.abs(degreeB - degreeA) % 360;
|
|
|
|
|
double distance = phi > 180 ? 360 - phi : phi;
|
|
|
|
|
|