summaryrefslogtreecommitdiff
path: root/src/RaceTrack.java
blob: 26119abf1c34dbec96cd5026827f287381239d20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74

import robotrace.Vector;
import static java.lang.Math.*;

/**
 * Implementation of a race track that is made from Bezier segments.
 */
class RaceTrack {

    /**
     * Array with control points for the O-track.
     */
    private Vector[] controlPointsOTrack;

    /**
     * Array with control points for the L-track.
     */
    private Vector[] controlPointsLTrack;

    /**
     * Array with control points for the C-track.
     */
    private Vector[] controlPointsCTrack;

    /**
     * Array with control points for the custom track.
     */
    private Vector[] controlPointsCustomTrack;

    /**
     * Constructs the race track, sets up display lists.
     */
    public RaceTrack() {
        // code goes here ...
    }

    /**
     * Draws this track, based on the selected track number.
     */
    public void draw(int trackNr) {

        // The test track is selected
        if (0 == trackNr) {
            // code goes here ...
        } else if (1 == trackNr) { // The O-track is selected
            // code goes here ...
        } else if (2 == trackNr) { // The L-track is selected
            // code goes here ...
        } else if (3 == trackNr) { // The C-track is selected
            // code goes here ...
        } else if (4 == trackNr) { // The custom track is selected
            // code goes here ...
        }
    }

    /**
     * Returns the position of the curve at 0 <= {@code t} <= 1.
     */
    public Vector getPoint(double t) {
        return new Vector(10 * cos(2 * PI * t),
                          14 * sin(2 * PI * t),
                          1);
    }

    /**
     * Returns the tangent of the curve at 0 <= {@code t} <= 1.
     */
    public Vector getTangent(double t) {
        // robot looks forward
        return new Vector(0,
                          1,
                          1);
    }
}