Part A

  1. Draw a torus.
  2. Modify the code to give every vertex an appropriate normal (see code below).
  3. Add code to place a light source above the torus and give the torus a shiny appearance. Run this application for an example.
  4. Compile and Execute.
  5. //==============================================
    //Parametric Eqn. of a Torus
    //==============================================
    
    //R=major radius
    //r=minor radius
    //u = parameter around 'Big' circle (0 -> 2PI)
    //v = parameter around 'Small' circle (0 -> 2PI)
    
    vertexX=((R+r*cos(u))*cos(v));
    vertexY=(r*sin(u));
    vertexZ=((R+r*cos(u))*sin(v));
    
    
    // compute normal for this vertex
    //(this formula only works for tori!)
    normalX=vertexX-(R*cos(v));
    normalY=vertexY;
    normalZ=vertexZ-(R*sin(v));
    

Part B

  1. Animate the scene so that the torus rotates but the light source is stationary.
  2. Compile and Execute.