summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank v/d Haterd <f.h.a.v.d.haterd@student.tue.nl>2013-12-18 15:42:02 +0100
committerFrank v/d Haterd <f.h.a.v.d.haterd@student.tue.nl>2013-12-18 15:42:02 +0100
commit84ebb68e5702b7288e1954b0c220061772761b9c (patch)
treea35752ae147eb58c15047f26437c2596e211d065
parent6a58fcca7e517714fd53543f194944d920867e2e (diff)
download2iv60-robots-84ebb68e5702b7288e1954b0c220061772761b9c.tar.gz
getTangent 2.1 finished and constants
-rw-r--r--src/RaceTrack.java19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/RaceTrack.java b/src/RaceTrack.java
index c973fb5..78e6e89 100644
--- a/src/RaceTrack.java
+++ b/src/RaceTrack.java
@@ -6,8 +6,15 @@ import static java.lang.Math.*;
* Implementation of a race track that is made from Bezier segments.
*/
class RaceTrack {
- protected static final int ellipse_a = 10;
- protected static final int ellipse_b = 14;
+ /**
+ * Halfwidth of the ellipse.
+ */
+ protected static final int ELLIPSE_A = 10;
+
+ /**
+ * Halfheight of the ellipse.
+ */
+ protected static final int ELLIPSE_B = 14;
/**
* Array with control points for the O-track.
@@ -61,8 +68,8 @@ class RaceTrack {
* Returns the position of the curve at 0 <= {@code t} <= 1.
*/
public Vector getPoint(double t) {
- return new Vector(ellipse_a * cos(2 * PI * t),
- ellipse_b * sin(2 * PI * t),
+ return new Vector(ELLIPSE_A * cos(2 * PI * t),
+ ELLIPSE_B * sin(2 * PI * t),
1);
}
@@ -88,8 +95,8 @@ class RaceTrack {
*/
Vector p = getPoint(t);
- return new Vector(-p.y()/(ellipse_a * ellipse_a),
- p.x()/(ellipse_b * ellipse_b),
+ return new Vector(-p.y()/(ELLIPSE_A * ELLIPSE_A),
+ p.x()/(ELLIPSE_B * ELLIPSE_B),
0).normalized();
}
}