mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Calculation of upwind downwind leg given a boat, wind and next mark now works. created GeometryUtils class
Can accurately calculate if a boat is going upwind or downward using a line function for the wind vector from the gate and the boat position from the gate. Requires knowledge of the next mark which requires the boat to have passed a mark. This could be fixed by extracting the leg number from the race status packet and mapping these to gates in an initalisation step tags: #story[956]
This commit is contained in:
@@ -435,7 +435,7 @@ public class CanvasController {
|
||||
return findScaledXY (unscaled.getLatitude(), unscaled.getLongitude());
|
||||
}
|
||||
|
||||
private Point2D findScaledXY (double unscaledLat, double unscaledLon) {
|
||||
public Point2D findScaledXY (double unscaledLat, double unscaledLon) {
|
||||
double distanceFromReference;
|
||||
double angleFromReference;
|
||||
int xAxisLocation = (int) referencePointX;
|
||||
@@ -468,4 +468,8 @@ public class CanvasController {
|
||||
List<BoatGroup> getBoatGroups() {
|
||||
return boatGroups;
|
||||
}
|
||||
|
||||
List<MarkGroup> getMarkGroups() {
|
||||
return markGroups;
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,9 @@ import seng302.controllers.annotations.ImportantAnnotationController;
|
||||
import seng302.controllers.annotations.ImportantAnnotationDelegate;
|
||||
import seng302.controllers.annotations.ImportantAnnotationsState;
|
||||
import seng302.models.*;
|
||||
import seng302.models.mark.GateMark;
|
||||
import seng302.models.mark.Mark;
|
||||
import seng302.models.mark.MarkGroup;
|
||||
import seng302.models.stream.StreamParser;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -185,14 +188,29 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
|
||||
for (Yacht yacht : StreamParser.getBoatsPos().values()) {
|
||||
|
||||
if (yacht.getLastMarkRounded() != null) {
|
||||
System.out.println("\n\nboat: " + yacht.getBoatName());
|
||||
System.out.println("last Mark: " + yacht.getLastMarkRounded().getName());
|
||||
}
|
||||
if (yacht.getNextMark() != null){
|
||||
System.out.println("next Mark: " + yacht.getNextMark().getName());
|
||||
for (BoatGroup bg : includedCanvasController.getBoatGroups()) {
|
||||
bg.calculateLegDirection();
|
||||
|
||||
Boolean isUpwindLeg = null;
|
||||
// Can only calc leg direction if there is a next mark and it is a gate mark
|
||||
Mark nextMark = bg.getBoat().getNextMark();
|
||||
if (!(nextMark == null || !(nextMark instanceof GateMark))) {
|
||||
isUpwindLeg = bg.isUpwindLeg(includedCanvasController);
|
||||
}
|
||||
|
||||
for (MarkGroup mg : includedCanvasController.getMarkGroups()) {
|
||||
if (mg.getMainMark().equals(nextMark)) {
|
||||
|
||||
}
|
||||
}
|
||||
if (isUpwindLeg != null) {
|
||||
if (isUpwindLeg) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user