Added method in mark group to draw lay lines, also added next mark to Yacht class.

#story[956]
This commit is contained in:
Michael Rausch
2017-05-23 18:54:42 +12:00
parent e1b8e19966
commit ca8ea03870
4 changed files with 67 additions and 1 deletions
@@ -45,6 +45,36 @@ public class MarkGroup extends Group {
super.getChildren().add(markCircle);
}
private Point2D getPointRotation(Point2D ref, Double distance, Double angle){
Double newX = ref.getX() + (ref.getX() + distance -ref.getX())*Math.cos(angle) - (ref.getY() + distance -ref.getY())*Math.sin(angle);
Double newY = ref.getY() + (ref.getX() + distance -ref.getX())*Math.sin(angle) + (ref.getY() + distance -ref.getY())*Math.cos(angle);
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
*/
private void addLayLine(Point2D startPoint, Double layLineAngle, Double baseAngle){
Point2D ep1 = getPointRotation(startPoint, 50.0, baseAngle + -layLineAngle);
Point2D ep2 = getPointRotation(startPoint, 50.0, baseAngle + layLineAngle);
Line line1 = new Line(startPoint.getX(), startPoint.getY(), ep1.getX(), ep1.getY());
Line line2 = new Line(startPoint.getX(), startPoint.getY(), ep2.getX(), ep2.getY());
line1.setStrokeWidth(0.5);
line1.setStroke(Color.GREEN);
line2.setStrokeWidth(0.5);
line2.setStroke(Color.GREEN);
super.getChildren().addAll(line1, line2);
}
public MarkGroup(GateMark mark, Point2D points1, Point2D points2) {
marks.add(mark.getSingleMark1());
marks.add(mark.getSingleMark2());
@@ -84,6 +114,8 @@ public class MarkGroup extends Group {
}
super.getChildren().add(line);
addLayLine(points1, 12.0, 90.0);
addLayLine(points2, 12.0, 90.0);
}
public void moveMarkTo (double x, double y, long raceId)