Initial work on calculating when a gate is upwind or downwind

Need to know if a gate is upwind or downwind to use the appropriate polar table

Currently calculate the angle between the next mark and the vector of the current mark to the wind, if this angle is less than 90 degrees than the next mark should be down wind

Pretty poor implementation currently, just prototype

Doesn't appear to be working as intended currently. Just a prototype for how we could implement further

tags: #story[956]
This commit is contained in:
William Muir
2017-05-24 00:08:55 +12:00
parent ca8ea03870
commit 89464e033e
3 changed files with 41 additions and 7 deletions
@@ -12,6 +12,7 @@ import javafx.scene.shape.Line;
import javafx.scene.shape.Polygon;
import javafx.scene.text.Text;
import javafx.scene.transform.Rotate;
import seng302.models.mark.Mark;
import seng302.models.stream.StreamParser;
import java.text.DateFormat;
@@ -363,6 +364,36 @@ public class BoatGroup extends Group {
}
public void calculateLegDirection() {
Mark lastMark = boat.getLastMarkRounded();
Mark nextMark = boat.getNextMark();
if (lastMark == null || nextMark == null) {
return;
}
Double windDirection = StreamParser.getWindDirection();
Double arbitraryDistance = 10d;
Point2D lastMarkMidPoint = new Point2D(lastMark.getLatitude(), lastMark.getLongitude());
Point2D nextMarkMidPoint = new Point2D(nextMark.getLatitude(), nextMark.getLongitude());
Double windDirX = lastMarkMidPoint.getX() + (lastMarkMidPoint.getX() + arbitraryDistance -lastMarkMidPoint.getX())*Math.cos(windDirection) - (lastMarkMidPoint.getY() + arbitraryDistance -lastMarkMidPoint.getY())*Math.sin(windDirection);
Double windDirY = lastMarkMidPoint.getY() + (lastMarkMidPoint.getX() + arbitraryDistance -lastMarkMidPoint.getX())*Math.sin(windDirection) + (lastMarkMidPoint.getY() + arbitraryDistance -lastMarkMidPoint.getY())*Math.cos(windDirection);
Point2D windDirPoint = new Point2D(windDirX, windDirY);
Double angle = lastMarkMidPoint.angle(nextMarkMidPoint, windDirPoint);
if (angle <= 90) {
System.out.println(lastMark.getName() + " is downwind");
System.out.println(nextMark.getName() + " is upwind");
}
// if (lastMarkMidPoint.angle(nextMarkMidPoint, windDirPoint) <= 90) {
// boat.getNextMark().s
// }
}
public void setIsSelected(Boolean isSelected) {
this.isSelected = isSelected;
setTeamNameObjectVisible(isSelected);
@@ -114,6 +114,9 @@ public class MarkGroup extends Group {
}
super.getChildren().add(line);
//Laylines
// if (mark.)
addLayLine(points1, 12.0, 90.0);
addLayLine(points2, 12.0, 90.0);
}