1 / 23

Trig Review and Drawing Curves with Depth Buffer for Curved Surfaces

This article provides a review of trigonometry concepts and explains how to draw curves on curved surfaces using the depth buffer technique. It also includes examples of parametric equations for circles and helixes. The article demonstrates how to indicate depth in pictures using the glFrustum function.

larrymurphy
Download Presentation

Trig Review and Drawing Curves with Depth Buffer for Curved Surfaces

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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. 1.0 0.0 cos(0) = sin(0) = (cos(0), sin(0))

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

  5. -1.0 0.0 cos(PI) = sin(PI) = (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-DDepth BufferPerspective

  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) y = Rsin(t) z = t - 60.0 -10*PI <= t <= 10*PI

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

  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);

More Related