Computer Graphics Computer Graphics Computer Graphics Computer Graphics
CSC CSC480 476 Chapter Three Chapter Three
Computer Graphics C S 4 8
This Week
- Windows, Viewports and Clippings
- Creating Useful Drawing Tools
- Turtle Graphics
This Week Windows, Viewports and Clippings Creating Useful Drawing - - PDF document
CSC CSC480 476 Chapter Three Chapter Three
Computer Graphics C S 4 8
Computer Graphics C S 4 8
where x and y were plotted as positive pixel values.
keeping track of pixels like this.
coordinates in which they are given.
negative values.
Computer Graphics C S 4 8
world, world coordinates, world windows, the screen window and the viewport.
Computer Graphics C S 4 8
Screen
The World (what you can see, the real world) Screen Window The World Window (the bit we want to capture) Viewport
Computer Graphics C S 4 8
size or have the same aspect ratio.
shrunk and moved to make them fit.
Computer Graphics CS 480 `
World Window Example Viewports
Computer Graphics CS 480 ´
World Window Viewport (0,0) (0,0) (100,0) (100,0) This is called Mapping
Computer Graphics CS 480 ^
achieved!!
Computer Graphics C S 4 8
translation (moving).
can be any aligned rectangle.
the entire screen window.
4/6/2009 Computer Graphics C S 4 8 4/6/2009 Computer Graphics C S 4 8
`
4/6/2009 Computer Graphics C S 4 8
Mapping from the Window to the Viewport
window is described by its left, top, right, and bottom borders as W.l, W.t, W.r, and W.b
V.l, V.t, V.r, and V.b
Computer Graphics C S 4 8
W.t = Window top W.l = Window left W.b = Window bottom W.r = Window right V.t = Viewport top V.l = Viewport left V.b = Viewport bottom V.r = Viewport right
´
Computer Graphics C S 4 8
xmin, ymin, xmax, ymax = W.l, W.b, W.r, W.t SCREENWIDTH = V.r – V.l SCREENHEIGHT = V.t – V.b
4/6/2009 Computer Graphics C S 4 8
the screen window coordinates for any given point (x, y) in the world. sx = Ax + C, sy = By + D
A C
^
Computer Graphics CS 480 `
b W t W b W y b V t V b V sy . . . . . . − − = − −
− − − + − − = b W b W t W b W t V b V y b W t W b V t V sy . . . . . . . . . .
B D
4/6/2009 Computer Graphics CS 480 ´
Using the formulas in Equation 3.3, we obtain A = 180, C = 40, B = 240, and D = 60. Thus, for this example, the window-to-viewport mapping is sx = 180x + 40; sy = 240y + 60.
4/6/2009 Computer Graphics CS 480 ^
PRACTICE EXERCISE
world window of (-10.0,10.0, -6.0,6.0) and a viewport of (0,600,0,400). What about the -ve values ??
Computer Graphics C S 4 8
Example What are A, B, C & D ??
World Window Viewport World Window Viewport
(10,6) (-10,-6) 400 600
Computer Graphics C S 4 8
calculations each time you draw something with OpenGL??
Computer Graphics C S 4 8
hard work for you.
that you understand what is going on…..
Computer Graphics C S 4 8
drawn (e.g. glVertex2f() etc..) the the coordinates of the point are passed coordinates of the point are passed through a set of transformations through a set of transformations that map world coordinates into viewport coordinates.
Computer Graphics C S 4 8
coordinates with:
void glOrtho2D(GLDouble left, GLDouble right, GLDouble bottom, GLDouble top);
void glViewport(GLint xmin, GLint ymin, GLint width, GLint height);
4/6/2009 Computer Graphics C S 4 8
prototypes void void gluOrtho D(GLdouble gluOrtho2D(GLdouble left, GLdouble right left, GLdouble , GLdouble bottom right, GLdouble , GLdouble bottom, GLdouble top top); ); which sets the window to have a lower left corner of (left, bottom) and an upper right corner of (right, top), and void void gIViewport(GLint x, GLint gIViewport(GLint , GLint width , GLint y, GLint , GLint height width, GLint height); ); which sets the viewport to have a lower left corner of (x, y) and an upper right corner of (x + width, y + height). By default, the viewport is the entire screen window:
If W and H are the width and height of the screen window, respectively, the
default viewport has lower left corner at (0, 0) and upper right corner at (W, H).
4/6/2009 Computer Graphics C S 4 8
must be preceded by two "setup" functions: gIMatrixMode (GL_PROJECTION) gILoadIdentity() // sets the window gIMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho gluOrtho2D( D(0.0, , 2.0, , 0.0, , 1.0);
);
// sets the viewport gIViewport( gIViewport(40 40, , 60 60, , 360 360, , 240 240);
);
4/6/2009 Computer Graphics CS 480 `
In Figures 2.10 and 2.17, the programs used the following instructions:
glutInitWindowSize(640,480); // set screen window size This instruction sets the size of the screen window to 640 by 480. The default viewport was used, since no gIViewport () The default viewport was used, since no gIViewport () command was issued; the default viewport is the command was issued; the default viewport is the entire screen window entire screen window.
glMatrixMode(GL_PROJECTION); gILoadIdentity(); gluOrtho2D(0.0, 640.0, 0.0, 480.0);
Computer Graphics CS 480 ´
Example
World Window Viewport
(10,6) (-10,-6) 400 600
Computer Graphics CS 480 ^
void myInit(void) { glClearColor(1.0,1.0,1.0,0.0); glColor3f(0,0,0); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); //set the viewing coordinates
gluOrtho2D(-10.0, 10.0, -6.0, 6.0); glViewport(0,0,600,400);
}
Computer Graphics C S 4 8
glPointSize(10.0); glBegin(GL_POINTS); glVertex2i(-10,-6); glVertex2i(0,0); glVertex2i(10,6); glEnd(); *NOTE: Vertex are given in World Coordinates and OpenGL maps them to the Viewport Coordinates.
Computer Graphics C S 4 8
//--------------- setWindow
setWindow(GLdouble left, Gldouble right, GLdouble bottom, GLdouble top) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluOrtho2D(left, right, bottom, top); } //---------------- setViewport
setViewport(GLdouble left, Gldouble right, GLdouble bottom, GLdouble top) { glViewport(left, bottom, right – left, top - bottom); }
Computer Graphics C S 4 8
//set the viewing coordinates setWindow(xmin, xmax, ymin, ymax); setViewport(0,640,0,480); glBegin(GL_POINTS); for(GLdouble x = xmin; x < xmax; x+=0.005 ) { glVertex2d(x, pow(2.7183, -x)*cos(2*3.14*x)); } glEnd();
`
4/6/2009 Computer Graphics C S 4 8
sinc(x) = [sin(PI *x)] / PI * x
void myDisplay(void) // plot the sine function, using world coordinates { setWindow(-5.0, 5.0, -0.3, 1.0); // set the window setViewport(0, 640, 0, 480); // set the viewport glBegin(GL_LINE_STRIP); for(GLfloat x = -4.0; x < 4.0; x += 0.1) // draw the plot glVertex2f(x, sin(3.14159 * x) / (3.14159 * x)); glEnd(); glFlush(); }
4/6/2009 Computer Graphics C S 4 8
Laying lots of copies of the same thing side by side to cover the entire screen window is called tiling the window. The picture that is copied at different positions is often called a motif.
tiling the window tiling the window
´
4/6/2009 Computer Graphics C S 4 8
Tiling a screen window is easily achieved by using a different viewport for each instance of the motif. The Fig. shows a tiling involving 25 copies
setWindow(0, 640.0, 0, 440.0); // set a fixed window for(int i=0; i < 5; i++) // for each column for(int j=0; j < 5; j++) // for each row { glViewport(i * 64, j * 44, 64, 44); // set the next viewport drawPolylineFile("dino.dat"); // draw it again }
Note that each copy is drawn in a viewport of size 64 by 44 pixels whose aspect ratio (64/44) matches that
the world
drawn without distortion. void void gIViewport gIViewport(GLint (GLint x, GLint , GLint y, GLint , GLint width width, GLint , GLint height height); );
4/6/2009 Computer Graphics C S 4 8
Shows another tiling, but here alternate motifs are flipped upside down to produce an intriguing effect. This was done by flipping the window upside down every other iteration: interchanging the top and bottom values in setWindow () for(int i = 0 ; i < 5; i++) for(int j = 0; j < 5; j++) { if((i+j) % 2 == 0) // if (i+j) is even
setWindow(0.0, 640.0, 440.0, 0.0); // upside-down else setWindow(0 . 0 , 640.0, 0.0, 440.0); // right-side-up glViewport(i * 64, j * 44, 64, 44); // set the next viewport drawPolylineFile("dino.dat"); // draw it again }
?
^
4/6/2009 Computer Graphics CS 480 `
Automatically
Setting of the Window
Often, the programmer does not know where the object
Like the dinosaur earlier, the object might be stored in a stored in a file file, or it might be generated procedurally generated procedurally by some algorithm whose details are not known.
it is convenient to let the application determine a good window to use determine a good window to use.
4/6/2009 Computer Graphics CS 480 ´
Windows and Viewports Windows and Viewports
– To zoom in on an object and create an animation, we need to create a number of frames and draw one after the other.
4/6/2009 Computer Graphics CS 480 ^
[A] Setting the Window [A] Setting the Window
consider the scene you are trying to capture.
4/6/2009 Computer Graphics C S 4 8
[A] Setting the Window [A] Setting the Window
need to predetermine the size of the coordinates to be captured.
maximum extent of these coordinates.
4/6/2009 Computer Graphics C S 4 8
[A] Setting the Window [A] Setting the Window
twice:
1. Execute the drawing routine, but don’t do any drawing. 2. Execute the drawing routine again, but this time draw!
4/6/2009 Computer Graphics C S 4 8
[A] Setting the Window [A] Setting the Window
GLdouble ytemp; for(GLdouble x = xmin+0.005; x < xmax; x+=0.005 ) { ytemp = pow(2.7183,
if (ytemp > ymax) ymax = ytemp; if (ytemp < ymin) ymin = ytemp; } setWindow(xmin, xmax, ymin, ymax); glBegin(GL_POINTS); for(GLdouble x = xmin; x < xmax; x+=0.005 ) { glVertex2d(x, pow(2.7183,
} glEnd();
Pass 1 to calculate suitable ymin and ymax Pass 2
Set the window boundaries
4/6/2009 Computer Graphics C S 4 8
[B] Setting the Viewport
viewport, you need to ensure the viewport and the window have the same aspect ratio .
viewport viewport window window
4/6/2009 Computer Graphics C S 4 8
[B] Setting the Viewport
the rectangle is taller than wide.
wider than tall.
4/6/2009 Computer Graphics C S 4 8
Automatic Setting of the Viewport to Preserve the Aspect Ratio
ratio as the world window to avoid distortion version of a figure and will fit in the screen window.
be R and the screen window has width W and height H.
have a larger aspect ratio than the screen window (R >
W/H), or it may have a smaller aspect ratio (R < W/H).
4/6/2009 Computer Graphics C S 4 8
We consider each in turn.
Case (a): R > W/H. the viewport to match aspect ratio R will extend fully across the screen window, therefore, the viewport will have width W and height W/R, so it is set with the following command setViewport( setViewport(0, W, , W, 0, W/R); , W/R); Case (b): R < W/H. the viewport to match aspect ratio R will reach from the top to the bot-tom of the screen window. At its largest, the viewport will have height H, but width HR, so it is set with the command setViewport( setViewport(0, H * R, , H * R, 0, H); , H);
4/6/2009 Computer Graphics CS 480 `
Set the Viewport
a) R > W/H (where R is the aspect ratio of the world window)
be unused space above and/or below.
4/6/2009 Computer Graphics CS 480 ´
Set the Viewport
b) R < W/H (where R is the aspect ratio of the world window)
be unused space on the sides.
height of the screen window. setViewport(0,H*R,0,H);
4/6/2009 Computer Graphics CS 480 ^
Suppose the window has aspect ratio R = 1.6 and the screen window has H = 200 and W = 360, and hence, W/H = 1.8. Therefore, Case (b) applies, and the viewport is set to have a height of H = 200 pixels and a width of = H * R = 320 pixels.
Suppose R = 2 and the screen window is the same as in the previous example. Then Case (a) applies, and the viewport is set to have a height of W/R = 180 pixels and a width of W = 360 pixels.
4/6/2009 Computer Graphics C S 4 8
Resizing the Screen Window
at run time. This action generates a resize event that the system can respond to.
// specifies the function myReshape called on an resize event
When this function is executed, the system automatically passes it the new width and height of the screen window, which the function can then use in its calculations. (GLsizei is a 32-bit integer; see Figure 2.7.)
glutKeyboardFunc …
defaults to the window coordinates.
4/6/2009 Computer Graphics C S 4 8
Making a Matched Viewport
that both fits into the new screen window and has the same aspect ratio as the world window. Matching the aspect ratios of the viewport and world window in this way will prevent distortion in the new picture.
that does the desired matching:
4/6/2009 Computer Graphics C S 4 8
void myReshape(GLsizei W, GLsizei H) { if(R > W/H) // use (global) window aspect ratio setViewport(0, W, 0, W/R); else setViewport(0, H * R, 0, H); }
the aspect ratio R of the window) that will fit into the new screen window. The routine obtains the width and height of the new screen window through its arguments. The code is a simple embodiment of the result in Figure 3.16.
`
4/6/2009 Computer Graphics C S 4 8
PRACTICE EXERCISES Page 95 By the student
4/6/2009 Computer Graphics C S 4 8
Clipping Lines
algorithm, the Cohen-Sutherlan clipper, that computes which part (if any) of a line segment with endpoints p 1 and p2 lies inside the world window lies inside the world window and then reports back the endpoints of that part.
´
4/6/2009 Computer Graphics C S 4 8
possible actions of a clipper.
segment
function returns a value of 1.
function it returns a value of 0.
segment ED),| the function clips the portion of the segment that lies
passe( through it (e.g., like segment AE), the function clips both ends and returns value of 1.
4/6/2009 Computer Graphics C S 4 8
Left -- Above ---- Right --- Below
^
4/6/2009 Computer Graphics CS 480 `
Testing for a Trivial Accept or Trivial Reject
same position; both points are to the left of the window, or both are above, etc. How? Code1 AND Code2 != 0 . First, endpoint pairs are checked for trivial acceptance. If the line cannot be trivially accepted, region checks are done. Now logically AND together the two region codes. A non-zero result means the line must be totally outside the window. Why?
4/6/2009 Computer Graphics CS 480 ´
Chopping When There Is Neither Trivial Accept nor Trivial Reject
Cohen-
Sutherland algorithm uses a divide-and-conquer strategy. If the segment can be neither trivially accepted nor rejected, it is broken into two parts at one of the window
and is discarded. The other part is potentially visible, so the entire process is repeated for this segment against another of the four window boundaries.
4/6/2009 Computer Graphics CS 480 ^
do{ form the code words for p 1 and p2 if (trivial accept) return 1;
if (trivial reject) return 0; chop the line at the "next" window border;
against the left edge against the right edge against the bottom edge against the top edge
discard the "outside" part; }while(1); Thus, after at most four iterations, trivial acceptance or rejection is assured.
4/6/2009 Computer Graphics C S 4 8
Clipping Lines
Cohen-Sutherland Clipping Algorithm
Clipping when there is neither trivial accept nor reject.
end point inside the window and one outside, or;
These lines need to be chopped at the window border intersections.
4/6/2009 Computer Graphics C S 4 8
Clipping Lines
Cohen-Sutherland Clipping Algorithm
We need to determine where A is.
calculated using similar triangles..
delx e dely d =
4/6/2009 Computer Graphics C S 4 8
shows an example involving the right edge of the window.
Look to the book page 98
4/6/2009 Computer Graphics C S 4 8
Clipping Lines
Cohen-Sutherland Clipping Algorithm
We need to determine where A is.
e = p1.x – W.right delx = p2.x – p1.x; dely = p2.y – p1.y; d = e/delx * dely; p1.y += (W.right – p1.x) * dely/delx
4/6/2009 Computer Graphics C S 4 8
The type Point2 holds a 2D point, and the type RealRect holds an aligned rectangle. Both types are described fully in Section 3.4.)
int clipSegment(Point2& pi, Point2& p2, RealRect W) { do{
if (trivial accept) return 1; // some portion survives if (trivial reject) return 0; //no portion survives if (p1 is outside} { if (p1 is to the left) chop against the left edge else if (p1 is to the right) chop against the right edge else if (p1 is below) chop against the bottom edge else if (p1 is above) chop against the top edge } else // p2 is outside { if (p2 is to the left) chop against the left edge else if (p2 is to the right) chop against the right edge else if (p2 is below) chop against the bottom edge else if (p2 is above) chop against the top edge }
}while(1); }
4/6/2009 Computer Graphics C S 4 8
all four clips is shown in Figure 3.24.
The 1st clip changes p1 to A 2nd finds p1 still outside and bellow and so changes A to C Last changes p2 to D 3rd alters p2 to B
4/6/2009 Computer Graphics C S 4 8
4/6/2009 Computer Graphics CS 480 `
PRACTICE EXERCISE
3.3.1 Hand simulation of clipSegment () Go through the clipping routine by hand for the case of a window given by {left, right, bottom, top} = (30, 220, 50, 240) and the following line segments:
In each case, determine the endpoints of the clipped segment, and for a visual check, sketch the situation on graph paper.
4/6/2009 Computer Graphics CS 480 ´
Section: 3.4 and 3.5
4/6/2009 Computer Graphics CS 480 ^
Developing The CANVAS class
Some useful Supporting Classes
class Point2 //single point w/ floating point coordinates { public: Point2() {x = y = 0.0f;} //constructor 1 Point2(float xx, float yy) {x=xx; y=yy;} //constructor 2 void set(float xx, float yy) {x=xx; y=yy;} float getX() {return x;} float getY() {return y;} void draw(void) { glBegin(GL_POINTS); //draw this point glVertex2f((GLfloat)x, (GLfloat)y); glEnd(); } private: float x ,y; };
4/6/2009 Computer Graphics CS 480 `
class IntRect //aligned rectangle with integer coordinates, used for viewport { public: IntRect() {l = 0; r=100; b=0; t=100;} //constructors IntRect(int left, int right, int bottom, int top) {l = left; r=right; b=bottom; t=top;} void set(int left, int right, int bottom, int top) { l=left; r=right; b=bottom; t=top; } void draw(void); //draw this rectangle using OpenGL int getL(void) { return l; } int getR(void) { return r; } int getT(void) { return t; } int getB(void) { return b; } private: int l, r, b, t;
};
4/6/2009 Computer Graphics CS 480 `
class RealRect //simlar to IntRect but w/ floating points & used for world window { public: RealRect() {l = 0; r=100; b=0; t=100;} //constructors RealRect(float left, float right, float bottom, float top) {l = left; r=right; b=bottom; t=top;} void set(float left, float right, float bottom, float top) { l=left; r=right; b=bottom; t=top; } float getL(void) { return l; } float getR(void) { return r; } float getT(void) { return t; } float getB(void) { return b; } void draw(void); //draw this rectangle using OpenGL private: float l, r, b, t;
}; //<<End Support Classes>>>
4/6/2009 Computer Graphics CS 480 `
class Canvas { public: Canvas(int width, int height, char* windowTitle); //constructor void setWindow(float l, float r, float b, float t); void setViewport(int l, int r, int b, int t); IntRect getViewport(void); //divulge the viewport data RealRect getWindow(void); // divulge the window data float getWindowAspectRatio(void); void clearScreen(); void setBackgroundColor(float r, float g, float b); void setColor(float r, float g, float b); void lineTo(float x, float y); void lineTo(Point2 p); void moveTo(float x, float y); void moveTo(Point2 p); void moveRel(float dx, float dy); private: Point2 CP; //current position in the world IntRect viewport; //the current window RealRect window; //the current viewport
} ;
`
4/6/2009 Computer Graphics CS 480 `
Relative Drawing
the Canvas class from section 3.4 in the textbook.
as you will need to implement it.
4/6/2009 Computer Graphics CS 480 `
Relative Drawing
point on the canvas relative to the current drawing location.
The function moveRel() is simple: it just moves the CP through the displacement (dx, dy).
´
4/6/2009 Computer Graphics CS 480 `
void Canvas:: moveRel(float dx, float dy) { CP.set(CP.getX() + dx, CP.getY() + dy); }
The function lineRel(float dx, float dy) does this too, but it first draws a line from the old CP to the new one.
void Canvas:: lineRel( float dx, float dy) { float x = CP.getX() + dx, y = CP.getY() + dy ; lineTo(x,y); CP.set(x, y); }
4/6/2009 Computer Graphics CS 480 `
Turtle Graphics
moveto(), forward(), turn() turnTo(float angle) This function turns the turtle to given angle and is implemented as Void Canvas :: turnTo(float angle) { CD = angle;} turn (float angle) This function turns the turtle through angle degrees Void Canvas :: turn(angle) {CD += angle;} See page 107-110 for more details
^
4/6/2009 Computer Graphics CS 480 ` `
Void Canvas :: forward(float dist, int isVisible) { // Code …. See page 107 } Old world CP New world CP
4/6/2009 Computer Graphics CS 480 ` ´
4/6/2009 Computer Graphics CS 480 ` ^
Turtle Graphics
Example: Polyspirals
for( some iterations ) { forward(length, 1); turn(angle); length += increment; }
4/6/2009 Computer Graphics CS 480 ´
Turtle Graphics
Example: Polyspirals
float angle = 87, inc = 0.5;
4/6/2009 Computer Graphics CS 480 ´
Turtle Graphics
Example: Polyspirals
float angle = 170, inc = 1;
4/6/2009 Computer Graphics CS 480 ´
Turtle Graphics
Example: Polyspirals
float angle = 89.5, inc = 1;
4/6/2009 Computer Graphics CS 480 ´
3.6 Figures Based on Regular Polygons
sides have equal lengths equal lengths, and if adjacent sides meet at equal interior angles equal interior angles.
4/6/2009 Computer Graphics CS 480 ´
Regular Polygons
polygon we need to specify the centre, the radius and a rotation angle.
0 <= i <= n -1 The center is (0, 0)
4/6/2009 Computer Graphics CS 480 ´
void ngon(int n, float cx, float cy, float radius, float rotAngle) { //assumes global Canvas object, cvs if(n < 3) return ; //bad number of sides double angle = rotAngle * 3.14159265 / 180; // rotAngle is the starting angle = 0 for the
// above figure … angle in radians
double angleInc = 2 * 3.14159265 / n; //calculate angle increment cvs.moveTo(radius * cos(angle) + cx, radius * sin(angle) + cy); // (cx,cy) is the origin (0,0) for the above figure. for(int k=0; k<n; k++) //repeat n times { angle += angleInc; cvs.lineTo(radius * cos(angle) + cx, radius + sin(angle) + cy); } } The center point (cx, cy) 60o
4/6/2009 Computer Graphics CS 480 ´
Regular Polygons
ngon(6,0.0,0.0,50.0, 20.0); ngon(10,0.0,0.0,40.0, 30.0); ngon(4,0.0,0.0,30.0, 10.0); ngon(20,0.0,0.0,20.0, 5.0);
void ngon(int n, float cx, float cy, float radius, float rotAngle)
4/6/2009 Computer Graphics CS 480 ´ `
The rosette and the golden 5-rosette
every vertex to every other.
The 5, 11, and 17 rosettes
4/6/2009 Computer Graphics CS 480 ´ ´
Circles and Arcs
the number of vertices becomes larger.
void drawCircle(Point2 center, float radius) { const int numVerts = 50; // void ngon(int n, float cx, float cy, float radius, float rotAngle) ngon(numVerts, center.getX(), center.getY(), radius, 0); }
number of intermediate segments in circle
4/6/2009 Computer Graphics CS 480 ´ ^
Circles and Arcs
allow you to draw an arc.
need to know, the centre, the radius, the starting angle (a) and the sweep angle (b).
4/6/2009 Computer Graphics CS 480 ^
Circles and Arcs
The code is similar to ngon() however it allows an arc to be drawn, which means that the shape isn’t drawn around 360 degrees.
drawArc(Point2 center, float radius, float startAngle, float sweep)
{ // startAngle and sweep are in degrees const int n = 30; // number of intermediate segments in arc float angle = startAngle * 3.14159265 / 180; // starting angle in
radians
float angleInc = sweep * 3.14159265 /(180 * n); // angle increment float cx = center.getX(), cy = center.getY(); // get center cvs.moveTo( cx + radius * cos(angle), cy + radius * sin(angle)); for(int k = 1; k < n; k++) {angle += angleInc; cvs.lineTo(cx + radius * cos(angle), cy + radius * sin(angle));} }
4/6/2009 Computer Graphics CS 480 ^
Circles and Arcs
// set center with (0, 0) p.set(0.0,0.0); cvs.clearScreen(); glLineWidth(2.0);
//drawArc(center, radius,startAngle, sweep)
drawArc(p, 50,45,90); drawArc(p, 40,15,90); drawArc(p, 30,0,90); drawArc(p, 20,90,90);