The Skiing Triangle Program
by
Rosanna Haut
Project Description:
The triangle figure in this program
is one that could frequently be seen on any paper I came in contact with in my
youth. He has no name and his skills
include, but are not limited to, skiing.
His key feature is his beaming smile.
I consider this program to be a small testament to the endless hours of
enjoyment I derived from drawing this figure and his happy world of friends.
Project Goals:
These were my original project goals, which are met by this
program.
Future Project Goals:
These are possible summer activity for when I feel the need
to create something
Users Guide
Keyboard:
h - will bring up the help menu
r will reset the triangle to the top of the hill and camera orientation
q will quit the program
z will zoom the camera out
x will zoom the camera in
i will increase the angle selected in the triangle submenu
d will decrease the angle selected in the triangle submenu
Menu right-click with the mouse to bring up:
camera rotation rotate the camera about the top of the hill by left-clicking and moving with
the mouse.
triangle select an angle on the model to increase or decrease using i or d
animation select either animation1 in which the triangle moves down the hill
or use free style which allows you to set the figures position using the triangle
submenu and sends him down the hill.
quit will end the program
Sample Output and
Design Comments
Full Screen View of the Triangle this is in his original position
Here is a shot from animation1 from the animation menu
I created the ski hill by plotting the equation f(x,y) = 1/(1+x*x+y*y) and scaling it to a large size.
I played with several different equations in Maple before deciding on this one. I liked it because it was simple to compute. I have only implemented flat shading for the hill and still need to do smooth. I plotted several different ski paths the triangle could take by holding one of the parameters of f(x,y) constant or reducing them to one parameter. In the program, I set x to be zero and let z be independent so y = 1/(1+z*z). This gave a straight path down the hill.
Another good path I found was by letting x = t and z = t*sin(t) so y = 1/(1+t*t+(t*sin(t))*(t*sin(t))). This gave a curved path down the hill that might seem more natural for a skier to take but I still need to implement it (see the graph plotted in Maple below).
I also had to determine the angle at which to rotate the triangle so that his skis would be parallel to the surface and his body at right angles to the surface. I did this by find the vector tangent to the point he was standing on while skiing down. I calculated this vector by taking the first derivative of the path equation. I then had to test whether the curve was concave up or concave down at this spot to determine if I should rotate by the angle the tangent vector made with (0, 1, 0) or 90 minus this angle.
This shot shows how the triangle stays on the surface
Here is a position that I created from triangle submenu
I created the figure using cylinders, spheres and a cone from opengl. I texture mapped his smile from a drawing I created in Paint. The figure was animated using an idle function and timer functions.
The skybox surrounding the hill is from http://www.planethalflife.com/crinity/skyspace.htm
Problems:
My code has a large memory leak somewhere that I am still attempting to locate. It will run but may crash due to a shortage of memory.
Code:
Currently being fixed.