# 计算机图形代写 | COSC 3P98 Computer Graphics Assignment 2

(a) Initialization: [4] There are 2 initialization modes:

When drawing the points from any input mode, use glPointSize so that they are large enough to see.  (b) Convex hull: [15] Implement any one of the convex hull algorithms discussed in class on the vertices in part (a). A command “c” will begin the convex hull computation and rendering. Save the hull edges in a data structure (necessary for question 2).

(c) Hull peel: [6] Repeatedly apply the convex hull routine to the set of points to create a peel, which is as follows. Find the hull for the points and draw it. Remove these hull points from the set, and iterate on the remaining points. Continue until less than 3 points remain.

(d) Peels on point clusters. Select K random points in your set of points. K is supplied by user, and should be much less than the number of points total. For example, for 100 points, perhaps K=5. Then divide all the points in the set into 5 sets, where the points in each set is closest in distance to one of the 5 random points. Perform a hull peel on each of the 5 sets, and colour the peels on each of the K sets a different colour.

(d)Surface of a 3D function: Letting the user select  random points (a) and lattice (b) from the main question, let the 2D triangulated polygons define the polygonal mesh of the surface of a 3D function:  y = f(x, z).  (Note: we will treat the 2D version as vertices on the X-Z plane — more explanation of this in class!) Let the user select between 3 different 3D functions that you supply.  For example:

y = sin(x)*cos(y)*x*y

The coordinate system should be centered around (0,0,0), and X and Z should be permitted to be positive and negative. Then perform a 2D triangulation on the points, by applying it only to the (X,Z) coordinates (the triangulation in the main question does this). The resulting triangulation will take the form of polygons on the surface of the function. Insert the computed Y values into the vertex coordinates, and plot the 3D surface in OpenGL. The other 2 functions you supply should similarly be centered on the origin, with positive/negative X and Z values. Note that you should compute the Y values just once, and save the (X,Y,Z) coordinates in a table for efficient rendering in 3D. Use the code in “rotate2.c” to spin the surface in 3D, under user control.

(e)3D spherical hull peel. Define a loop that creates a new set of random points a distance d from the origin (0,0,0), computes and renders its hull, and then repeats the process a given number of times for smaller and smaller d values. The result should be a set of concentric hulls. They will tend to look like spheres if you use many points. Render the result using transparent surfaces (OpenGL’s alpha channel). You may also want to spin your object in 3D (see (d) above). This object is also easy to apply OpenGL lighting onto, because vertex normals are identical to vertex coordinates on a unit sphere centered at (0, 0, 0).