You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.3 KiB
84 lines
2.3 KiB
package seng302.Model;
|
|
|
|
import javafx.scene.paint.Color;
|
|
import org.geotools.referencing.GeodeticCalculator;
|
|
import seng302.GPSCoordinate;
|
|
|
|
|
|
|
|
/**
|
|
* Created by esa46 on 15/03/17.
|
|
*/
|
|
public class BoatInRace extends Boat {
|
|
|
|
private Leg currentLeg;
|
|
private double distanceTravelledInLeg;
|
|
private GPSCoordinate currentPosition;
|
|
private long timeFinished;
|
|
private Color colour;
|
|
|
|
public GPSCoordinate getCurrentPosition() {
|
|
return currentPosition;
|
|
}
|
|
|
|
public long getTimeFinished() {
|
|
return timeFinished;
|
|
}
|
|
|
|
public Color getColour() {
|
|
return colour;
|
|
}
|
|
|
|
public void setColour(Color colour) {
|
|
this.colour = colour;
|
|
}
|
|
|
|
public void setTimeFinished(long timeFinished) {
|
|
this.timeFinished = timeFinished;
|
|
}
|
|
|
|
|
|
public BoatInRace(String name, double velocity) {
|
|
super(name, velocity);
|
|
}
|
|
|
|
public Leg getCurrentLeg() {
|
|
return currentLeg;
|
|
}
|
|
|
|
public void setCurrentLeg(Leg currentLeg) {
|
|
this.currentLeg = currentLeg;
|
|
}
|
|
|
|
public double getDistanceTravelledInLeg() {
|
|
return distanceTravelledInLeg;
|
|
}
|
|
|
|
public void setCurrentPosition(GPSCoordinate position) {
|
|
this.currentPosition = position;
|
|
}
|
|
|
|
public void setDistanceTravelledInLeg(double distanceTravelledInLeg) {
|
|
this.distanceTravelledInLeg = distanceTravelledInLeg;
|
|
}
|
|
|
|
|
|
/**
|
|
* Calculates the bearing of the travel via map coordinates of the raceMarkers
|
|
* @return
|
|
*/
|
|
public double calculateHeading(){
|
|
//to be changed to coordinates when used to match reality.
|
|
GeodeticCalculator calc = new GeodeticCalculator();
|
|
calc.setStartingGeographicPoint(currentLeg.getStartGraphCoordinate().getLatitude(), currentLeg.getStartGraphCoordinate().getLongitude());
|
|
|
|
calc.setDestinationGeographicPoint(currentLeg.getEndGraphCoordinate().getLatitude(), currentLeg.getEndGraphCoordinate().getLongitude());
|
|
|
|
return calc.getAzimuth();
|
|
// double thetaHat = Math.atan2((currentLeg.getEndGraphCoordinate().getLatitude() - currentLeg.getStartGraphCoordinate().getLongitude()),
|
|
// (currentLeg.getEndGraphCoordinate().getLatitude() - currentLeg.getStartGraphCoordinate().getLongitude()));
|
|
// return thetaHat >= 0 ? Math.toDegrees(thetaHat): Math.toDegrees(thetaHat + 2 * Math.PI);
|
|
}
|
|
|
|
}
|