From 84ebb68e5702b7288e1954b0c220061772761b9c Mon Sep 17 00:00:00 2001 From: Frank v/d Haterd Date: Wed, 18 Dec 2013 15:42:02 +0100 Subject: getTangent 2.1 finished and constants --- src/RaceTrack.java | 19 +++++++++++++------ 1 file 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(); } } -- cgit v1.2.1