CSC418/2504F: Fall 2003 Assignment 2

Oct. 8, 2001. Due: Oct. 22, 2003 in class.

Solutions:

look here.

Answers to frequently-asked questions.

  1. Transformations [4 marks] Consider the following 2-dimensional coordinate frames A and B and C.

    1. [2 mark] What are the coordinates of point P in frames A, B and C (note that the vectors are not all unit length)?
    2. [2 marks] What is the 3x3 homogeneous matrix MBC that, when multiplied by a point in frame B, yields that point's coefficients in frame C?

     

  2. Viewing and Projection [6 marks]
    1. [3 marks] A typical property of perspective projection is that families of parallel lines all seem to converge to a point on the image plane. Is this true for all families of parallel lines? If so prove it, if not, given a viewpoint <0,0,0> and a view vector <3,4,0> describe all families of parallel lines that do not converge to a point and prove that all other families do converge to a point.  (Note: If a line is described by the parametric equation  A+Bt, its family of parallel lines is described by the vector B).
    2.  [2 marks] Write the eye-space and  projective transforms for the viewpoint and view vector above with up vector <0,0,1> and projection plane a distance of d from the viewpoint as 4x4 matrices. 
    3. [1 mark] Does the family of lines with direction vector <1,0,0> converge on the image plane defined above and if so write the point of convergence as a function of d.

     

  3. Modeling [4 marks]
    1. [2 marks] Given a triangulation of a polygon of n vertices, a new triangulation can be generated using an operation called a diagonal flip. Some four vertices of the polygon that form a quadrilateral with one diagonal (in the given triangulation) are chosen and the alternate diagonal is picked to generate a new triangulation. Given that the input triangulation is valid describe an algorithm to that return true/ false on whether a proposed diagonal flip results in a valid triangulation for a simple polygon.
    2. [1 mark] Describe a more efficient algorithm if the input polygon is convex.
    3. [1 mark] Given any two triangulations of a convex polygon with n vertices show that you can turn one triangulation into another using at most 2*(n-3) diagonal flips.

     

  4. Cartoon shading [8 marks]
    In cartoon tracing, silhouette edges of a model are drawn as a black outline. For this question we define a silhouette edge to be one for which one adjacent face is a front face and the other a back face with respect to a given viewpoint. Write a program to display  a cartoon shading of a mesh specified to stdin as follows:

    v 0 0 0

    v 1 0 0

    v 0 1 0

    v 0 0 1

    f 3 2 1

    f 1 2 4

    f 3 1 4

    f 2 3 4

    e 5 0 0 

    n -1 0 0

    u 0 1 0

    here lines beginning with v represent a vertex followed by its location in 3D, lines beginning with f represent faces with the numbers are an index to the vertices of the polygon (starting from 1), in order,

    e represents the viewpoint, n the view direction and u the up vector.

    In general the file is a number of vertices (one per line) written as  v <x> <y> <z>, followed by a number of faces (one per line) written as

    f <index1> <index2> ... <index n>,  followed by a viewpoint e <x> <y> <z>, view direction n <x> <y> <z> and up vector u <x> <y> <z>.  

    EXTRA CREDIT: [2 marks] interactively pan the viewpoint based on mouse motion, in the plane defined by the given vewpoint and view direction.

Submit your code electronically, using one of the following commands: Submit a printed copy as well.

  1. Hierarchies [8 marks] Write a program to draw and control this robot:
    Skeleton code is provided at Submit your code electronically, using one of the following commands: Submit a printed copy as well.