From f41858e2c7a2087422887cd58fb92b78b9386b29 Mon Sep 17 00:00:00 2001 From: Calum Date: Wed, 17 May 2017 17:35:59 +1200 Subject: [PATCH] Tidied variable names. --- src/main/java/seng302/models/Wake.java | 37 +++++++++++--------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/src/main/java/seng302/models/Wake.java b/src/main/java/seng302/models/Wake.java index 7c9bb14c..630b075a 100644 --- a/src/main/java/seng302/models/Wake.java +++ b/src/main/java/seng302/models/Wake.java @@ -56,38 +56,31 @@ class Wake extends Group { * Sets the rotationalVelocity of each arc. * * @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. */ - void setRotationalVelocity (double rotationalVelocity, double velocity) { + void setRotationalVelocity(double rotationalVelocity, double velocity) { rotationalVelocities[0] = rotationalVelocity; for (int i = 1; i < numWakes; i++) { - double difference = Math.atan2( - Math.sin( - Math.toRadians( - rotations[i - 1] - rotations[i] - ) - ), - Math.cos( - Math.toRadians( - rotations[i - 1] - rotations[i] - ) - ) + double wakeSeparationRad = Math.toRadians(rotations[i - 1] - rotations[i]); + double shortestDistance = Math.atan2( + Math.sin(wakeSeparationRad), + Math.cos(wakeSeparationRad) ); - difference = Math.toDegrees(difference); + double distDeg = Math.toDegrees(shortestDistance); - if (rotationalVelocities[i-1] < 0.01 && rotationalVelocities[i-1] > -0.01) { - rotationalVelocities[i] = difference / UNIFICATION_SPEED * Math.log(Math.abs(difference) + 1) / Math.log(MAX_DIFF / numWakes) * 1.5; + if (rotationalVelocities[i - 1] < 0.01 && rotationalVelocities[i - 1] > -0.01) { + rotationalVelocities[i] = distDeg / UNIFICATION_SPEED * Math.log(Math.abs(distDeg) + 1) / Math.log(MAX_DIFF / numWakes); } else { - if (difference < (MAX_DIFF / numWakes)) - rotationalVelocities[i] = rotationalVelocities[i-1] * Math.log(Math.abs(difference) + 1) / Math.log(MAX_DIFF / numWakes); + if (distDeg < (MAX_DIFF / numWakes)) + rotationalVelocities[i] = rotationalVelocities[i - 1] * Math.log(Math.abs(distDeg) + 1) / Math.log(MAX_DIFF / numWakes); else rotationalVelocities[i] = rotationalVelocities[i - 1]; } } double rad = baseRad + velocity; - for (Arc arc :arcs) { + for (Arc arc : arcs) { arc.setRadiusX(rad); arc.setRadiusY(rad); rad += (20 / numWakes) + (velocity / 2); @@ -96,9 +89,10 @@ class Wake extends Group { /** * Arcs rotate based on the distance they would have travelled over the supplied time interval. + * * @param timeInterval the time interval, in microseconds, that the wake should move. */ - void updatePosition (long timeInterval) { + void updatePosition(long timeInterval) { for (int i = 0; i < numWakes; i++) { rotations[i] = rotations[i] + rotationalVelocities[i] * timeInterval; arcs[i].getTransforms().setAll(new Rotate(rotations[i])); @@ -107,9 +101,10 @@ class Wake extends Group { /** * Rotate all wakes to the given rotation. + * * @param rotation the from north angle in degrees to rotate to. */ - void rotate (double rotation) { + void rotate(double rotation) { for (int i = 0; i < arcs.length; i++) { rotations[i] = rotation; rotationalVelocities[i] = 0;