MockBoat has autoVMG disabled by default.
Wind/Tack commands disable autoVMG. VMG command enables it. Upwind command was turning until boat was at 0 degrees, instead of being aligned with wind direction, but that's fixed. #story[1096]
This commit is contained in:
@@ -25,7 +25,7 @@ public class MockBoat extends Boat {
|
|||||||
/**
|
/**
|
||||||
* Stores whether the boat is on autoVMG or not
|
* Stores whether the boat is on autoVMG or not
|
||||||
*/
|
*/
|
||||||
private boolean autoVMG = true;
|
private boolean autoVMG = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,9 @@ public class TackGybeCommand implements Command {
|
|||||||
//The refactoring of MockRace will require changes to be made
|
//The refactoring of MockRace will require changes to be made
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
|
||||||
|
boat.setAutoVMG(false);
|
||||||
|
|
||||||
/*VMG newVMG = boat.getPolars().calculateVMG(
|
/*VMG newVMG = boat.getPolars().calculateVMG(
|
||||||
race.getWindDirection(),
|
race.getWindDirection(),
|
||||||
race.getWindSpeed(),
|
race.getWindSpeed(),
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ public class VMGCommand implements Command {
|
|||||||
//The refactoring of MockRace will require changes to be made
|
//The refactoring of MockRace will require changes to be made
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
boat.setAutoVMG(true);
|
||||||
/*VMG newVMG = boat.getPolars().calculateVMG(
|
/*VMG newVMG = boat.getPolars().calculateVMG(
|
||||||
race.getWindDirection(),
|
race.getWindDirection(),
|
||||||
race.getWindSpeed(),
|
race.getWindSpeed(),
|
||||||
|
|||||||
@@ -20,13 +20,17 @@ public class WindCommand implements Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
|
||||||
|
boat.setAutoVMG(false);
|
||||||
|
|
||||||
double wind = race.getWindDirection().degrees();
|
double wind = race.getWindDirection().degrees();
|
||||||
double heading = boat.getBearing().degrees();
|
double heading = boat.getBearing().degrees();
|
||||||
|
|
||||||
double offset = 3.0;
|
double offset = 3.0;
|
||||||
|
|
||||||
offset *= direction;
|
offset *= direction;
|
||||||
if(wind - heading < 0) offset *= -1;
|
double headWindDelta = wind - heading;
|
||||||
|
if ((headWindDelta < 0) || (headWindDelta > 180)) offset *= -1;
|
||||||
|
|
||||||
boat.setBearing(Bearing.fromDegrees(heading + offset));
|
boat.setBearing(Bearing.fromDegrees(heading + offset));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user