Presentation is loading. Please wait.

Presentation is loading. Please wait.

drawing curved surfaces

Similar presentations


Presentation on theme: "drawing curved surfaces"— Presentation transcript:

1 drawing curved surfaces
Class 3:Chaps 2 cont. trig review drawing curves depth buffer perspective drawing curved surfaces

2 Trig Review: Definition of sine and cosine (Unit circle, radius=1) (cos sin ) (cos sin ) From Wikipedia, modified

3 cos(0) = sin(0) = 1.0 0.0 (cos(0), sin(0))

4 cos(PI/2) = sin(PI/2) = 0.0 1.0 (cos(PI/2), sin(PI/2))

5 cos(PI) = sin(PI) = -1.0 0.0 (cos(PI), sin(PI))

6 Change the radius from 1 to R
(Rcos(), Rsin()) R

7 Move the center from (0,0) to (X,Y)
(X+Rcos(), Y+Rsin()) R (X,Y) Y X (0,0)

8 Curved Objects Run the program circle.cpp. Observe
instructions in comment and console screen global variables new version of color: glColor3ub use of rand() glutPostRedisplay in keyInput

9 parametric equation of circle

10 The book also has parabola.cpp,
another example of a curve described parametrically. Run it on your own.

11 3-D Depth Buffer Perspective

12 circularAnnuluses.cpp (modified)

13 Overwritten void drawDisc(float R, float X, float Y, float Z);
glColor3f(0.0, 0.0, 1.0); drawDisc(20.0, 25.0, 75.0, 0.0); glColor3f(1.0, 1.0, 1.0); drawDisc(10.0, 25.0, 75.0, 0.0);

14 The real deal if (isWire) glPolygonMode(GL_FRONT, GL_LINE);
else glPolygonMode(GL_FRONT, GL_FILL); glColor3f(1.0, 0.0, 0.0); glBegin(GL_TRIANGLE_STRIP); for(i = 0; i <= N; ++i) { angle = 2 * PI * i / N; glVertex3f(50 + cos(angle) * 10.0, 30 + sin(angle) * 10.0, 0.0); glVertex3f(50 + cos(angle) * 20.0, 30 + sin(angle) * 20.0, 0.0); } glEnd();

15 Floating glEnable(GL_DEPTH_TEST); // Enable depth testing.
glColor3f(0.0, 1.0, 0.0); drawDisc(20.0, 75.0, 75.0, 0.0); glColor3f(1.0, 1.0, 1.0); drawDisc(10.0, 75.0, 75.0, 0.5); // Compare this z-value with that of the green disc. glDisable(GL_DEPTH_TEST); // Disable depth testing.

16 To use the depth buffer, you must initialize it in main.
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); And clear it glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

17 Hidden surface removal.
glOrtho(0.0, 100.0, 0.0, 100.0, -1.0, 1.0);

18 What is it? x = Rcos(t) -10*PI <= t <= 10*PI y = Rsin(t)
z = t -10*PI <= t <= 10*PI

19 Helix.cpp x = Rcos(t) -10*PI <= t <= 10*PI y = Rsin(t)
z = t -10*PI <= t <= 10*PI _____ _____ z:

20 Helixmod.cpp cont after a modification of view

21 How do we indicate depth in pictures?

22 glFrustum(left, right, bottom, top, near, far)

23 glFrustum(-5.0,5.0,-5.0,5.0,4.0,100.0);


Download ppt "drawing curved surfaces"

Similar presentations


Ads by Google