Homework 5

Modified

  1. Implement a simple 3D function plotter that can plot a function of 2 variables. For example:

    GLfloat fy( GLFloat x, GLfloat z) { return 2*x*x+2*z*z-1.0; }

    when plotted for values x=-1..1 and z=-1..1 produces a 3D graph similar to the figure at right centered at the origin, when looking directly down the negative z-axis.

    Hint: To implement a general function plotter requires passing the function to be plotted. A function f can be passed a function as parameter p in C or C++ by defined as:

    void f( int p( int ), int y ) { printf( "%d", p( y ) ); }

    int square( int x ) { return x*x; }

    f( square, 3);        // Prints 9

     

  2. Create a cube world of a plane where a large cube is fixed and a smaller cube that can move and has the ability to walk through the sides of the large cube.

    There should be two viewing modes, one from a viewpoint on a hemisphere (from Question 1) viewing both cubes, the second from the small cube able to view its surroundings.

    Hints:

3. Modify Question 2 solution so that the big cube is replaced by the function plot from Question 1 and that the small cube can move through the plot.

EMAIL

  1. To  with subject: YOUR NAME: B481 and Homework 5.
  2. Send a Web accessible link to a zip file with your last name as Lastname.zip containing three directories:
    1. Directory named ONE for Question 1:
    1. Directory named TWO for Question 2:
    1. Directory named THREE for Question 3:
  3. Instructions on executing.