1 / 7

Drawing Curves

Drawing Curves. Lecture 10 Wed, Sep 17, 2003. Drawing Curves Parametrically . To draw a curve that is represented parametrically, we compute the x- and y-coordinates of points on the curve for a set of values of t. Drawing Curves Parametrically.

huslu
Download Presentation

Drawing Curves

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. Drawing Curves Lecture 10 Wed, Sep 17, 2003

  2. Drawing Curves Parametrically • To draw a curve that is represented parametrically, we compute the x- and y-coordinates of points on the curve for a set of values of t.

  3. Drawing Curves Parametrically • We regularly subdivide the range of t values into a collection of subintervals. • Over each subinterval we draw a straight line segment. • If there are too few points, then the curve looks polygonal. • If there are too many points, then the curve takes too long to draw.

  4. Drawing Curves Parametrically • We may • Compute the (x, y) coordinates anew each time the curve is drawn, or • Compute them once and store them in arrays. • Which method is better? • Which method would the Canvas class use?

  5. Drawing A Circle Parametrically • To draw a circle, first compute and store the coordinates of 40 points. float x[40]; float y[40]; float angle = 0.0; float dAngle = PI/20; for (int i = 0; i < 40; i++) { x[i] = cen.x + rad*cos(angle); y[i] = cen.y + rad*sin(angle); angle += dAngle; }

  6. Drawing A Circle Parametrically • Then use OpenGL functions to draw the circle. glBegin(GL_LINE_LOOP); for (int i = 0; i < 40; i++) glVertex2f(x[i], y[i]); glEnd();

  7. Example: Draw a Circle • DrawCircles.cpp

More Related