summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2013-12-23 12:43:08 +0100
committerPeter Wu <lekensteyn@gmail.com>2013-12-23 12:43:08 +0100
commitcafd122ab2ad90160a9a1f75917f1e03677fa861 (patch)
tree4bc0875c19d02493b3cd1d336e94210b5b90b1d5
parentcbfd16060e8352d7ea8f05d9bb8d58253243930d (diff)
download2iv60-robots-cafd122ab2ad90160a9a1f75917f1e03677fa861.tar.gz
Fix FP view eye point, whitespace fixes.
-rw-r--r--src/Camera.java12
-rw-r--r--src/RobotRace.java15
2 files changed, 11 insertions, 16 deletions
diff --git a/src/Camera.java b/src/Camera.java
index d2e4c4f..b519345 100644
--- a/src/Camera.java
+++ b/src/Camera.java
@@ -16,7 +16,7 @@ class Camera {
/** The up vector. */
public Vector up = Vector.Z;
-
+
/** Race track used. */
private RaceTrack track;
@@ -113,7 +113,7 @@ class Camera {
/* look in the direction where the robots walks, namely the tangent
Add the actual robot position to the tangent vector, and calculate
the normal vector based on the resulting vector. This is the up vector. */
- Vector robotPos = track.getPointForLane(focus.getTimePos(),
+ Vector robotPos = track.getPointForLane(focus.getTimePos(),
focus.getLane());
Vector robotTangent = track.getTangent(focus.getTimePos());
Vector totalVector = robotTangent.add(robotPos);
@@ -160,17 +160,17 @@ class Camera {
// trivial: looks from the robot POV.
eye = track.getPointForLane(focus.getTimePos(), focus.getLane());
// robots are two meter, look from head.
- eye.add(new Vector(0, 0, 3f));
+ eye = eye.add(new Vector(0, 0, 2f));
// The question is similar to question 2b of the intermediate test
// http://www.win.tue.nl/~vanwijk/2IV60/2IV60_test_exam_161213_answers.pdf
// C(t) = E(t) + P'(t) (P'(t) is the tangent vector).
Vector robotTangent = track.getTangent(focus.getTimePos());
- Vector robotPos = track.getPointForLane(focus.getTimePos(),
+ Vector robotPos = track.getPointForLane(focus.getTimePos(),
focus.getLane());
-
+
Vector centerPoint = robotPos.add(robotTangent);
-
+
center = new Vector(-centerPoint.y(), centerPoint.x(), 3f);
// trivial: look forward, so up vector points up.
diff --git a/src/RobotRace.java b/src/RobotRace.java
index ee7fbcc..b3f28d0 100644
--- a/src/RobotRace.java
+++ b/src/RobotRace.java
@@ -378,11 +378,6 @@ public class RobotRace extends Base {
// to 0 means robot is matching expected and great means that
// we have a turtle.
double jitter = current_t - robot.getTimePos();
-
-
-
-
-
// TODO: do not use static speed
robot.setSpeed(TARGET_ROBOT_SPEED);
}
@@ -413,18 +408,18 @@ public class RobotRace extends Base {
// put robot centered on the lane, slightly rotated to look forward
Vector robotPos = raceTrack.getPointForLane(robot.getTimePos(), i);
gl.glTranslated(robotPos.x(), robotPos.y(), robotPos.z());
-
+
/* Calculate angle for the robots to look at, multiply by 180/PI
* to convert the radions to degrees.
* First get the tangent of the robot, that is the real direction
- * where the robot is looking to.
- * Then add this vector to the actual position, and from the
+ * where the robot is looking to.
+ * Then add this vector to the actual position, and from the
* resulting vector we can calculate the angle. */
Vector robotTangent = raceTrack.getTangent(robot.getTimePos());
Vector totalVector = robotTangent.add(robotPos);
-
+
double angle = atan2(totalVector.y(), totalVector.x()) * 180/PI;
-
+
gl.glRotated(angle, 0, 0, 1);
// Draw the current robot