/************************************************************************* FILE: surface.cc Functions used to generate curves and surfaces. Author: Dana Vrajitoru, IUSB Class: C481 B581 Computer Graphics **************************************************************************/ #include #include "Point3f.h" // Builds a circle in the xy plane with given center and radius made // of 20 points. The first point is repeated a the end to create a // loop. It stores the points and normals in the last two // parameters. This is supposed to be drawn as a line strip. void circleXy(float centerx, float centery, float centerz, float radius, vector3f &points, vector3f &normals) { Point3f p, n; p[2] = centerz; n[2] = 0; const int nrPoints = 20; float angle =0, delta_angle = 2*M_PI/nrPoints; for (int i=0; i<=nrPoints; i++) { angle += delta_angle; // The normal in the point : we want it to be a unit vector. n[0] = cos(angle); n[1] = sin(angle); // We can use the normat to compute the point itself. p[0] = centerx +radius * cos(angle); p[1] = centery +radius * sin(angle); // Add these to the points and normals. points.push_back(p); normals.push_back(n); } } // Draws a curve as a line strip; we have no use for the normals for a // line strip. void drawLineStrip(vector3f &points) { glBegin(GL_LINE_STRIP); for (int i=0; i