Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

%%%%%%MATLAB%%%%%%% contents of roller_coaster.dat -3.0000000000000000e+00 5.555

ID: 3600396 • Letter: #

Question

%%%%%%MATLAB%%%%%%%

contents of roller_coaster.dat

-3.0000000000000000e+00   5.5555555555555486e+01   1.6432748538011685e+02   8.4234470182877303e+01
-2.0000000000000000e+00 -8.0116959064327546e+01   1.5964912280701742e+02   4.9972597362134451e+01
-1.0000000000000000e+00 -1.0467836257309943e+02   4.7368421052631561e+01   4.3902488765921390e+01
   0.0000000000000000e+00 -1.3040935672514621e+02 -5.7894736842105260e+01   1.4905708324568812e+01
   1.0000000000000000e+00 -1.3157894736842104e+02 -1.2456140350877189e+02   4.6371356064551115e+01
   2.0000000000000000e+00 -4.1520467836257353e+01 -1.7017543859649118e+02   5.8981748960474313e+01
   3.0000000000000000e+00   1.0233918128654960e+02 -1.6315789473684208e+02   1.8717207053983863e+01
   4.0000000000000000e+00   1.6666666666666652e+02 -6.6081871345029242e+01   6.1133014663795151e+01
   5.0000000000000000e+00   1.6666666666666652e+02   6.8421052631578902e+01   5.1941981368346042e+00
   6.0000000000000000e+00   1.4561403508771917e+02   1.5146198830409350e+02   5.7572694845372126e+01
   7.0000000000000000e+00   5.5555555555555486e+01   1.6432748538011685e+02   8.4234470182877303e+01
   8.0000000000000000e+00 -8.0116959064327546e+01   1.5964912280701742e+02   4.9972597362134451e+01
   9.0000000000000000e+00 -1.0467836257309943e+02   4.7368421052631561e+01   4.3902488765921390e+01
   1.0000000000000000e+01 -1.3040935672514621e+02 -5.7894736842105260e+01   1.4905708324568812e+01
   1.1000000000000000e+01 -1.3157894736842104e+02 -1.2456140350877189e+02   4.6371356064551115e+01
   1.2000000000000000e+01 -4.1520467836257353e+01 -1.7017543859649118e+02   5.8981748960474313e+01
   1.3000000000000000e+01   1.0233918128654960e+02 -1.6315789473684208e+02   1.8717207053983863e+01
   1.4000000000000000e+01   1.6666666666666652e+02 -6.6081871345029242e+01   6.1133014663795151e+01

The unit normal vector N(t) is given by N(t) =-11 g(t)r"(t)- g'(t)r'(t) r"(t) × r"(t)112 ll where r(t) = [x(t) y(t) z(t)]T denotes the position vector on the track and g(t) = llr'(t)ll,-V(z'(t))2 + (y'(t))2 + (z'(t))2. The cur vature of the track is given as ,(t) x r'(t)112 (g(t))3 n(t) = Plugging these into the tormula for the acceleration gives: ait) =-S2 g(t)r'"(t)-g"(t)r'(t) g(t))3

Explanation / Answer

In the first assignment you used some basic OpenGL functionality but didn't get into anything really interesting (unless you went nuts with extra credit).

This assignment asks you to utilize some more interesting features of the OpenGL library in the design of a more significant and entertaining application. In addition, this project gives you a great deal more freedom to be creative in the actual design of your program and the features that go into it; you are asked to create your own solutions to issues involved in the making of your simulation, and to render your coaster as you wish in a world of your design.

After completing this assignment, you should have a solid understanding of:

This assignment should be challenging, and will likely take a significant amount of time. However, this should also be a lot of fun! Please start early

Background Information

In order to create the track for your roller coaster, you'll need to render a spline sequence which represents the entire length of your track. Rather than using provided functions, you will be implementing a spline function yourself. This function should take four control points (p0 through p3) and a floating point value (u) from 0 to 1 to trace along the length of the line defined by these four control points. Drawing a single spline from four control points isn't that exciting—you'll need to use several control points in sequence and draw spline segments along them, starting from the first four points and proceeding until you draw the final spline for the last four points. This will allow you to represent a long, elaborate curve for your coaster.

We'll be using Catmull-Rom splines for the representation of your coaster. These will be defined in lecture but you can also look at notes here.

Your Implementation

Make sure you understand Catmull-Rom splines pretty well, then on to the coding itself.

Before doing anything else, you'll probably want to visually check your function by drawing some splines to the screen. We provide a set of "track" files containing control points to define some simple spline shapes, and starter code to read in a sequence of these files and convert them to sequences of control points that you can use. It's definitely a good idea to write the code to draw a simple spline sequence and test this before moving on to later parts of the assignment.

Next, try setting up the world in which you will actually place your coaster. You can use a plane for the ground—this should be texture-mapped for realism with an image of your choice. There are plenty of free texture sites on the Web, so google one that appeals to you. After this, create your sky as you wish—this should also be texture-mapped, and the method of modelling it is up to you. There are issues with many obvious representations, so think about this carefully. Make sure that you can still draw splines as before once you have this set up. Note that the "sky" includes the horizon as well, so simply having a single plane above and a single one below does not constitute an entire sky.

Now, implement the ability to ride the coaster. It's easiest to start with your camera moving at constant speed (in u) along the spline before worrying about realism. Properly orienting your camera is a challenging problem! You'll want to have your camera facing "forward" (along the tangent to your spline) as it moves. Also, you need to make the "up" vector of your camera follow some continuous path of normals to the spline. A cheap method to decide your up vector is to always set it equal to the normal of your ground plane—however, this is totally unrealistic for many splines (think about what happens with loops). Another method is here. Both of these have their limitations, so you are encouraged to come up with another solution to this problem. This document may also be useful.

Modify the appearance of the coaster itself—instead of just a line, make your track look like a track! Draw some sort of cross-section, and add whatever details you like. Add lighting to make your coaster look more realistic!