mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 06:18:44 +00:00
Trying to get laylines to display on proper respective sides of the gate
Having a great time here, Not quite working. There was an issue where the laylines are crossed and I think its tied to the fact that sometimes the two seperate points of the gate mark appear to have the same x y coordinate so the line function doesnt work? idk tags: #story[956] #pair[wmu16]
This commit is contained in:
@@ -22,6 +22,7 @@ import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import javafx.util.Duration;
|
||||
import javafx.util.StringConverter;
|
||||
import seng302.GeometryUtils;
|
||||
import seng302.controllers.annotations.Annotation;
|
||||
import seng302.controllers.annotations.ImportantAnnotationController;
|
||||
import seng302.controllers.annotations.ImportantAnnotationDelegate;
|
||||
@@ -213,7 +214,7 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
if (legNumber == 0) {
|
||||
System.out.println("PreStart");
|
||||
return null;
|
||||
} else if (legNumber == markSequence.size() - 2) {
|
||||
} else if (legNumber == markSequence.size() - 1) {
|
||||
System.out.println("Finishing");
|
||||
return null;
|
||||
}
|
||||
@@ -329,8 +330,17 @@ public class RaceViewController extends Thread implements ImportantAnnotationDel
|
||||
|
||||
Double resultingAngle = angleAndSpeed.keySet().iterator().next();
|
||||
|
||||
mg.addLayLine(markPoint1, 180 - resultingAngle, StreamParser.getWindDirection());
|
||||
mg.addLayLine(markPoint2, 180 - resultingAngle, StreamParser.getWindDirection());
|
||||
|
||||
Point2D boatCurrentPos = new Point2D(bg.getLayoutX(), bg.getLayoutY());
|
||||
Point2D gateMidPoint = markPoint1.midpoint(markPoint2);
|
||||
Integer lineFuncResult = GeometryUtils.lineFunction(boatCurrentPos, gateMidPoint, markPoint2);
|
||||
if (lineFuncResult == 1) {
|
||||
mg.addRightLayline(markPoint2, 180 - resultingAngle, StreamParser.getWindDirection());
|
||||
mg.addLeftLayline(markPoint1, 180 - resultingAngle, StreamParser.getWindDirection());
|
||||
} else if (lineFuncResult == -1) {
|
||||
mg.addRightLayline(markPoint1, 180 - resultingAngle, StreamParser.getWindDirection());
|
||||
mg.addLeftLayline(markPoint2, 180 - resultingAngle, StreamParser.getWindDirection());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import javafx.scene.Group;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Circle;
|
||||
import javafx.scene.shape.Line;
|
||||
import seng302.GeometryUtils;
|
||||
|
||||
/**
|
||||
* Created by CJIRWIN on 26/04/2017.
|
||||
@@ -52,27 +53,27 @@ public class MarkGroup extends Group {
|
||||
return new Point2D(newX, newY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a lay-line to the MarkGroup
|
||||
* @param startPoint The mark where the lay line starts
|
||||
* @param layLineAngle The angle the laylines point
|
||||
* @param baseAngle The reference angle
|
||||
*/
|
||||
public void addLayLine(Point2D startPoint, Double layLineAngle, Double baseAngle){
|
||||
|
||||
Point2D ep1 = getPointRotation(startPoint, 50.0, baseAngle + -layLineAngle);
|
||||
Point2D ep2 = getPointRotation(startPoint, 50.0, baseAngle + layLineAngle);
|
||||
public void addLeftLayline(Point2D startPoint, Double layLineAngle, Double baseAngle) {
|
||||
|
||||
Line line1 = new Line(startPoint.getX(), startPoint.getY(), ep1.getX(), ep1.getY());
|
||||
Line line2 = new Line(startPoint.getX(), startPoint.getY(), ep2.getX(), ep2.getY());
|
||||
Point2D ep = getPointRotation(startPoint, 50.0, baseAngle + layLineAngle);
|
||||
Line line = new Line(startPoint.getX(), startPoint.getY(), ep.getX(), ep.getY());
|
||||
line.setStrokeWidth(1);
|
||||
line.setStroke(Color.GREEN);
|
||||
|
||||
line1.setStrokeWidth(0.5);
|
||||
line1.setStroke(Color.GREEN);
|
||||
super.getChildren().addAll(line);
|
||||
|
||||
line2.setStrokeWidth(0.5);
|
||||
line2.setStroke(Color.GREEN);
|
||||
}
|
||||
|
||||
public void addRightLayline(Point2D startPoint, Double layLineAngle, Double baseAngle) {
|
||||
|
||||
Point2D ep = getPointRotation(startPoint, 50.0, baseAngle - layLineAngle);
|
||||
Line line = new Line(startPoint.getX(), startPoint.getY(), ep.getX(), ep.getY());
|
||||
line.setStrokeWidth(1);
|
||||
line.setStroke(Color.GREEN);
|
||||
|
||||
super.getChildren().addAll(line);
|
||||
|
||||
super.getChildren().addAll(line1, line2);
|
||||
}
|
||||
|
||||
public MarkGroup(GateMark mark, Point2D points1, Point2D points2) {
|
||||
|
||||
@@ -427,6 +427,8 @@ public class StreamParser extends Thread{
|
||||
}));
|
||||
}
|
||||
markPositions.get(boatId).put(markPacket);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user