VMG is now working and fixed, however, it feels a bit odd #story[1182]
This commit is contained in:
@@ -368,9 +368,9 @@ public class MockRace extends Race {
|
||||
VMG newVMG = NewPolars.setBestVMG(this.getWindDirection(), this.getWindSpeed(), boat.getBearing());
|
||||
//System.out.println(newVMG);
|
||||
//If the new vmg improves velocity, use it.
|
||||
if (improvesVelocity(boat, newVMG)) {
|
||||
boat.setVMG(newVMG);
|
||||
}
|
||||
/*if (improvesVelocity(boat, newVMG)) {
|
||||
}*/
|
||||
boat.setVMG(newVMG);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,18 +106,25 @@ public class NewPolars {
|
||||
private static double getBestSpeedInQuadrant(int quad, Map<Double, Double> set){
|
||||
double min = (quad - 1)* 90;
|
||||
double max = quad * 90;
|
||||
System.out.println(quad);
|
||||
System.out.println(min + " " + max);
|
||||
//System.out.println(quad);
|
||||
//System.out.println(min + " " + max);
|
||||
double maxAngle = 0;
|
||||
double maxSpeed = 0;
|
||||
double dupAngle = 0;//index where speed is duplicated
|
||||
for (Double s: set.keySet()){
|
||||
if (s >= min && s < max){
|
||||
if (set.get(s) > maxSpeed){
|
||||
dupAngle = 0;
|
||||
maxAngle = s;
|
||||
maxSpeed = set.get(s);
|
||||
} else if (set.get(s) == maxSpeed){
|
||||
dupAngle = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}/*
|
||||
if (dupAngle != 0 ){
|
||||
return getClosest((dupAngle + maxAngle) / 2, set.keySet());
|
||||
}*/
|
||||
return maxAngle;
|
||||
}
|
||||
|
||||
@@ -140,14 +147,16 @@ public class NewPolars {
|
||||
Bearing vmgAngle = Bearing.fromDegrees((bestAngle) % 360);
|
||||
double boatSpeed = polars.get(closestSpeed).get(bestAngle);
|
||||
|
||||
return new VMG(boatSpeed, Bearing.fromDegrees(vmgAngle.degrees() + trueWindAngle.degrees()));
|
||||
double newAngle = (bestAngle + trueWindAngle.degrees() % 360 + 360) % 360;
|
||||
|
||||
return new VMG(boatSpeed, Bearing.fromDegrees(newAngle));
|
||||
}
|
||||
|
||||
public static double calculateSpeed(Bearing trueWindAngle, double trueWindSpeed, Bearing boatAngle){
|
||||
//speed
|
||||
double closestSpeed = getClosest(trueWindSpeed, polars.keySet());
|
||||
|
||||
double angleDiff = Math.abs(trueWindAngle.degrees() - boatAngle.degrees()) % 180;
|
||||
double angleDiff = ((boatAngle.degrees() - trueWindAngle.degrees()) % 360 + 360) % 360;
|
||||
double closestAngle = getClosest(angleDiff, polars.get(closestSpeed).keySet());
|
||||
|
||||
double boatSpeed = polars.get(closestSpeed).get(closestAngle);
|
||||
@@ -162,4 +171,16 @@ public class NewPolars {
|
||||
return polars;
|
||||
}
|
||||
|
||||
private void printOutLinearInterpolated(){
|
||||
for (double tws: polars.keySet()){
|
||||
System.out.println("==================================================");
|
||||
System.out.println("Speed: " + tws);
|
||||
System.out.println("==================================================");
|
||||
for (double twa: polars.get(tws).keySet()){
|
||||
System.out.println("TWA: " + twa + ", Boat Speed: " + polars.get(tws).get(twa));
|
||||
//System.out.println("--------------------------------------------------");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user