Added/improved documentation

#chore
This commit is contained in:
Calum
2017-05-15 15:36:18 +12:00
parent 89ef6e5277
commit 8fbb9d6d4e
2 changed files with 53 additions and 54 deletions
+17 -18
View File
@@ -8,30 +8,29 @@ import javafx.scene.shape.StrokeLineCap;
import javafx.scene.transform.Rotate; import javafx.scene.transform.Rotate;
/** /**
* By default wake is a group containing 5 arcs. Each arc starts from the same point. Each arc is larger and more * A group containing objects used to represent wakes onscreen. Contains functionality for their animation.
* transparent than the last. On calling updatePositions() arcs rotate at velocities given by setRotationalVelocity().
* The larger and more transparent an arc is the longer the delay before it rotates at the latest velocity. It is
* assumed that rotationalVelocities() are set regularly as wakes do not stop rotating and an array of velocities needs
* to be populated for the class to work as expected.
*/ */
class Wake extends Group { class Wake extends Group {
//Wake Settings. Should probably be hard coded in when the final values are decided upon. //Wake Settings.
//Changes the relationship between separation of wakes and velocity. Only logarithmic is guaranteed to work always since it's my favourite :/.
private enum functionType {LINEAR, LOGARITHMIC, POWER, ROOT, POWOUT_LOGIN} private enum functionType {LINEAR, LOGARITHMIC, POWER, ROOT, POWOUT_LOGIN}
private functionType wakeFunction = functionType.LOGARITHMIC; private functionType wakeFunction = functionType.LOGARITHMIC;
//Change the wake style. Currently can be ArcType.OPEN or ArcType.ROUND
private ArcType arcType = ArcType.OPEN; private ArcType arcType = ArcType.OPEN;
//The number of wakes
private int numWakes = 10; private int numWakes = 10;
private double offSet = 0; //The total possible difference between the first wake and the last. Increasing/Decreasing this will make wakes fan out more/less.
private final double MAX_DIFF = 75.0; private final double MAX_DIFF = 75;
//Increasing/decreasing this will alter the speed that wakes converge when the heading stop changing. Anything over about 1500 may cause oscillation.
private final int UNIFICATION_SPEED = 500; private final int UNIFICATION_SPEED = 500;
//The power used for the power function. Changing this will probably break stuff in a cool way.
private final int POWER = 2; private final int POWER = 2;
private Arc[] arcs = new Arc[numWakes]; private Arc[] arcs = new Arc[numWakes];
private double[] rotationalVelocities = new double[numWakes]; private double[] rotationalVelocities = new double[numWakes];
private double[] rotations = new double[numWakes]; private double[] rotations = new double[numWakes];
private double baseRad; private double baseRad;
private boolean spawnNewWake = false;
private int count = 10;
/** /**
* Create a wake at the given location. * Create a wake at the given location.
@@ -65,8 +64,8 @@ class Wake extends Group {
} }
/** /**
* Sets the rotationalVelocity of each arc. Each arc is 3 velocities behind the next smallest arc. The smallest uses * Sets the rotationalVelocity of each arc.
* the latest given velocity. *
* @param rotationalVelocity The rotationalVelocity the wake should move at. * @param rotationalVelocity The rotationalVelocity the wake should move at.
* @param velocity The real world velocity of the boat in m/s. * @param velocity The real world velocity of the boat in m/s.
*/ */
@@ -89,11 +88,11 @@ class Wake extends Group {
if (wakeFunction == functionType.LOGARITHMIC) { if (wakeFunction == functionType.LOGARITHMIC) {
if (rotationalVelocities[i-1] < 0.01 && rotationalVelocities[i-1] > -0.01) { if (rotationalVelocities[i-1] < 0.01 && rotationalVelocities[i-1] > -0.01) {
rotationalVelocities[i] = (MAX_DIFF / numWakes) / UNIFICATION_SPEED * Math.log(Math.abs(difference) + 1) / Math.log(MAX_DIFF / numWakes) * 1.5; rotationalVelocities[i] = difference / UNIFICATION_SPEED * Math.log(Math.abs(difference) + 1) / Math.log(MAX_DIFF / numWakes) * 1.5;
if (difference < 0) // if (difference < 0)
{ // {
rotationalVelocities[i] = -rotationalVelocities[i]; // rotationalVelocities[i] = -rotationalVelocities[i];
} // }
} else { } else {
rotationalVelocities[i] = rotationalVelocities[i-1] * Math.log(Math.abs(difference) + 1) / Math.log(MAX_DIFF / numWakes); rotationalVelocities[i] = rotationalVelocities[i-1] * Math.log(Math.abs(difference) + 1) / Math.log(MAX_DIFF / numWakes);
} }
@@ -148,7 +147,7 @@ class Wake extends Group {
// } else { // } else {
// offSet += baseRad / 5; // offSet += baseRad / 5;
// } // }
double rad = baseRad + velocity + offSet; double rad = baseRad + velocity;
for (Arc arc :arcs) { for (Arc arc :arcs) {
arc.setRadiusX(rad); arc.setRadiusX(rad);
arc.setRadiusY(rad); arc.setRadiusY(rad);
@@ -126,42 +126,42 @@ public class MarkGroup extends RaceObject {
} }
public void updatePosition (long timeInterval) { public void updatePosition (long timeInterval) {
// Circle markCircle = (Circle) super.getChildren().get(0); Circle markCircle = (Circle) super.getChildren().get(0);
//
// if (nodePixelVelocitiesX[0] > 0 && markCircle.getCenterX() > nodeDestinations[0].getX() || if (nodePixelVelocitiesX[0] > 0 && markCircle.getCenterX() > nodeDestinations[0].getX() ||
// nodePixelVelocitiesX[0] < 0 && markCircle.getCenterX() < nodeDestinations[0].getY()) nodePixelVelocitiesX[0] < 0 && markCircle.getCenterX() < nodeDestinations[0].getY())
// nodePixelVelocitiesX[0] = 0; nodePixelVelocitiesX[0] = 0;
// else if (nodePixelVelocitiesX[0] != 0) else if (nodePixelVelocitiesX[0] != 0)
// markCircle.setCenterX(markCircle.getCenterX() + nodePixelVelocitiesX[0] * timeInterval); markCircle.setCenterX(markCircle.getCenterX() + nodePixelVelocitiesX[0] * timeInterval);
//
// if (nodePixelVelocitiesY[0] > 0 && markCircle.getCenterY() > nodeDestinations[0].getY() || if (nodePixelVelocitiesY[0] > 0 && markCircle.getCenterY() > nodeDestinations[0].getY() ||
// nodePixelVelocitiesY[0] < 0 && markCircle.getCenterY() < nodeDestinations[0].getY()) nodePixelVelocitiesY[0] < 0 && markCircle.getCenterY() < nodeDestinations[0].getY())
// nodePixelVelocitiesY[0] = 0; nodePixelVelocitiesY[0] = 0;
// else if (nodePixelVelocitiesY[0] != 0) else if (nodePixelVelocitiesY[0] != 0)
// markCircle.setCenterY(markCircle.getCenterY() + nodePixelVelocitiesY[0] * timeInterval); markCircle.setCenterY(markCircle.getCenterY() + nodePixelVelocitiesY[0] * timeInterval);
//
// if (mainMark.getMarkType() != MarkType.SINGLE_MARK) { if (mainMark.getMarkType() != MarkType.SINGLE_MARK) {
//
// Line line = (Line) super.getChildren().get(2); Line line = (Line) super.getChildren().get(2);
// line.setStartX(markCircle.getCenterX()); line.setStartX(markCircle.getCenterX());
// line.setStartY(markCircle.getCenterY()); line.setStartY(markCircle.getCenterY());
//
// markCircle = (Circle) super.getChildren().get(1); markCircle = (Circle) super.getChildren().get(1);
//
// if (nodePixelVelocitiesX[1] > 0 && markCircle.getCenterX() >= nodeDestinations[1].getX() || if (nodePixelVelocitiesX[1] > 0 && markCircle.getCenterX() >= nodeDestinations[1].getX() ||
// nodePixelVelocitiesX[1] < 0 && markCircle.getCenterX() <= nodeDestinations[1].getX()) nodePixelVelocitiesX[1] < 0 && markCircle.getCenterX() <= nodeDestinations[1].getX())
// nodePixelVelocitiesX[1] = 0; nodePixelVelocitiesX[1] = 0;
// else if (nodePixelVelocitiesX[1] != 0) else if (nodePixelVelocitiesX[1] != 0)
// markCircle.setCenterX(markCircle.getCenterX() + nodePixelVelocitiesX[1] * timeInterval); markCircle.setCenterX(markCircle.getCenterX() + nodePixelVelocitiesX[1] * timeInterval);
//
// if (nodePixelVelocitiesY[1] > 0 && markCircle.getCenterY() > nodeDestinations[1].getY() || if (nodePixelVelocitiesY[1] > 0 && markCircle.getCenterY() > nodeDestinations[1].getY() ||
// nodePixelVelocitiesY[1] < 0 && markCircle.getCenterY() < nodeDestinations[1].getY()) nodePixelVelocitiesY[1] < 0 && markCircle.getCenterY() < nodeDestinations[1].getY())
// nodePixelVelocitiesY[1] = 0; nodePixelVelocitiesY[1] = 0;
// else if (nodePixelVelocitiesY[1] != 0) else if (nodePixelVelocitiesY[1] != 0)
// markCircle.setCenterY(markCircle.getCenterY() + nodePixelVelocitiesY[1] * timeInterval); markCircle.setCenterY(markCircle.getCenterY() + nodePixelVelocitiesY[1] * timeInterval);
// line.setEndX(markCircle.getCenterX()); line.setEndX(markCircle.getCenterX());
// line.setEndY(markCircle.getCenterY()); line.setEndY(markCircle.getCenterY());
// } }
} }
public void moveGroupBy (double x, double y, double rotation) { public void moveGroupBy (double x, double y, double rotation) {