mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
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:
@@ -184,17 +184,17 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
updateBoatSelectionComboBox();
|
||||
|
||||
for (Yacht yacht : StreamParser.getBoatsPos().values()) {
|
||||
System.out.println("\n\nyacht.getBoatName() = " + yacht.getBoatName());
|
||||
System.out.println("yacht.getLastMarkRounded() = " + yacht.getLastMarkRounded());
|
||||
System.out.println("yacht.getNextMark() = " + yacht.getNextMark());
|
||||
|
||||
if (yacht.getLastMarkRounded() != null) {
|
||||
System.out.println(yacht.getLastMarkRounded().getName());
|
||||
} else {
|
||||
System.out.println("sup");
|
||||
System.out.println("\n\nboat: " + yacht.getBoatName());
|
||||
System.out.println("last Mark: " + yacht.getLastMarkRounded().getName());
|
||||
}
|
||||
if (yacht.getNextMark() != null){
|
||||
System.out.println("yacht = " + yacht.getNextMark().getName());
|
||||
System.out.println("next Mark: " + yacht.getNextMark().getName());
|
||||
for (BoatGroup bg : includedCanvasController.getBoatGroups()) {
|
||||
bg.calculateLegDirection();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user