Author:

Joseph Chenoweth(soj@cats.ucsc.edu)

Files Required:

  • viewport.cpp
  • viewport.h
  • final.cpp
  • final.h
  • Makefile
  • One of the following:

    Other important notes:

    None

    Compiling:

    Type "make" to compile.
    "make clean" will remove all .o files and the executable.

    Running:

    Type "final" to run the program.

    User's Guide

    Here is a screenshot of the interface:


    The Wall controls effect where the next wall will appear and what color it will be. Press the Create Wall Button to make a wall. It is suggested that both walls and spheres not be white or grey as the currently selected sphere or plane is white. The position that the next wall or sphere is show as a transparent wall or sphere.

    The ball controls effect the positioning, size, velocity and color of the next ball to be created.

    Press Delete Selected Object to delete the selected object. The selected object is white.

    The Gravity slider effects the gravity applied to the spheres.

    Speed Adjustment effects how fast the simulation is carried out.

    Camera controls do just that: Control the camera.

    Exit exits the program.

    The ticks on the reference lines point in the positive direction and are every 10 units. Red is the X direction, Green is the Y direction, Blue is the Z direction.



    Program Background

    I wanted to extend some collision detection code that I had been working on. The basis of the code is the fact that you can not only calculate the distance to an infinite plane from any point, but also which side of the plane any point happens to lay on.
    Since calculating distance is not a problem, one can easily detect if a sphere has collided with a plane.
    Once it has been determined that the sphere and the plane are intersecting, one must simply determine if the intersection point between the sphere and the plane happens to lay within a bounded area.
    This can be accomplished with the use of trigonometry and the fact that all of the angles of the lines from the intersection point to the corners of the bounded area should add up to 360 degrees.

    The second problem this program faced was how to determine if two spheres had collided. This was accomplished just by calculating the distance between the spheres and seeing if that was less than their radii. If it was, a collision had occured.