Representations for Lines and Curves

Size: px
Start display at page:

Download "Representations for Lines and Curves"

Transcription

1 Computer Graphics Drawing algorithms for two-dimensional graphics primitives Ref: Computer Graphics, 2nd Edition, with C, by Hearn and Baker, Prentice-hall, Inc., Representations for Lines and Curves A preliminary step to drawing lines and curves is choosing a suitable representation for them. There are three possible choices which are potentially useful. 1. Explicit: y = f(x) Line: Circle: 2

2 Representations for Lines and Curves (cont.) 2. Parametric: Line: x = f(t), y = f(t) Circle: 3 Representations for Lines and Curves (cont.) 3. Implicit: f(x,y) = 0 Line: Circle: 4

3 Optimal Line Drawing Drawing lines on a raster grid implicitly involves approximation. The general process is called rasterization or scan-conversion conversion. What is the best way to draw a line from the pixel (x 1,y 1 ) to (x 2,y 2 )? Such a line should ideally have the following properties. straight pass through endpoints smooth independent of endpoint order uniform brightness brightness independent of slope 5 Scan Conversion: Lines ( DDA Algorithm ) DDA (Digital( Differential Analyzer) Algorithm Line equation: y = mx + b m = (y(2) - y(1)) / (x(2) - x(1)) b = y(1) - m x(1) Differential line equation: dy = m dx,, i.e., dy = y(k+1) - y(k) = m if dx=1 dx = x(k+1) - x(k) = 1/m if dy=1 If slope is less than 1, increment x by 1, and y(k+1) = y(k) + m If slope is greater than 1, increment y by 1, and x(k+1) = x(k) + 1/m Problems: round off error slow 6

4 Implementation of DDA Algorithm A Straightforward Implementation void DrawLine(int x1, int y1, int x2, int y2) { float y; int x; for (x = x1; x< = x2; x++) { y = y1 + (x - x1) * (y2 - y1)/(x2 - x1); SetPixel(hdc, x, Round(y) ); // end for x // end of DrawLine A Better Implementation DrawLine(int int x1, int y1, int x2, int y2) { float m,y; int dx, dy,, x; dx = x2 - x1; dy = y2 - y1; m = dy / dx; y = y ; for (x=x1; x<=x2; x++) { SetPixel(x, Floor(y) ); y = y + m; 7 Scan Conversion: Lines (Bresenham Algorithm) Bresenham s s Line Algorithm, 1965 (Midpoint Line Algorithm) Basic Concepts: Line equation 1: F=ax+ x+by+ y+c=0 (1) Line equation 2: if a point u(x,y) is on a line, F = u v = (x-x1 x1)dy - (y-y1 y1)dx = (dy)x x + (-dx)y y +(y1dx+ (y1dx-x1dy) x1dy) = 0 (2) Comparing Eqs.. (1) and (2) yields a = dy, b = -dx, c = const. Deviation d d =F -F= F= (ax +by +by +c) +c)-(ax+by+c) = a x + b y = dy x - dx y We also note that F > 0 if point (x,y) is on the right-hand hand side or below the line F = 0 if point (x,y) is on the line 8 F < 0 if point (x,y) is on the left-hand side or above the line v u(x,y)

5 Detail of the Midpoint Line Algorithm The midpoint algorithm is better than the DDA algorithm in that it uses only integer calculations. It treats line drawing as a sequence of decisions. For those lines with slope m<1 If a pixel is to be drawn, the next pixel, E or NE, can be chosen by computing F(x p +1, y p +0.5) and testing its sign Define: d=f(x p +1, y p +0.5) If d 0, midpoint is on the lhs of line, choose E If d > 0, midpoint is on the rhs of line, choose NE Case 1: if E is chosen, x=1, y=0 (d( 0) 9 d d = dy x - dx y d new = d old + d 即函數 d (=F) 實際上只須求一次 Detail of the Midpoint Line Algorithm (continued) Case 2: if NE is chosen, x x = y y = 1 d d = dy x - dx y For the first pixel at (xo,yo,yo), the first midpoint is at (x( o +1, y o +0.5). Thus, d=f(x,y) = (x-x1 x1)dy - (y-y1 y1)dx Note: the value of dx/2 may not be an integer Since we would like an integer-only algorithm, we can multiply the decision variable D by two as follows 10

6 11 Implementation of Bresenham s Line Algorithm void DrawLine(int x1, int y1, int x2, int y2, int color) { int dx = x2 - x1; int dy = y2 - y1; int d = 2 * dy dx; int x = x1; int y = y1; for (i = 0; i < dx ; i++) { SetPixel(x, y, color); If (d > 0) { y = y + 1; d = d -2* dx; // end if d > 0 x = x + 1; d = d + 2 * dy; //note: d = d 2 * dx + 2 * dy if d > 0 // end for I // end of DrawLine ***Only suitable for slope m 1*** d start =2 =2dy - dx d d = 2dy - 2dx ( if d > 0, NE is chosen ) d d = 2dy (if d 0, E is chosen) d new =d old old + d Polygons Different types of polygons: Triangles are often particularly nice to work with because they are always planar and simple convex. 12

7 Polygon Representations A variety of polygon representations can be used, one of the most common ones being an ordered list of references to a vertex list. This avoids redundant storage and redundant computations. We'll also be associating a variety of other information with vertices, such as normals,, colors, and texture coordinates. 13 A Simple Example: Cube 14

8 Scan Conversion: Polygon The job of scan conversion is to shade pixels lying within a closed polygon, and to do so efficiently. The fill color will in general depend on the lighting, texture,, and visibility of the polygon being scan-converted. converted. These will be ignored for the time being. It is assumed that the polygon is closed and has ordered edges. 15 Scan Conversion Algorithm for Polygons The scan conversion algorithm then works as follows: intersect each scan line with all edges sort intersections in x calculate parity of intersections to determine in/out fill the 'in' pixels Special cases: horizontal edges can be excluded vertices lying on scan lines! change in sign of slope: count twice! no change in sign: shorten edge by one scan line 16

9 The Coherence Between Adjacent Scan Lines Taking advantage of coherence ( 連貫性 ) between adjacent scan lines can eliminate many intersection tests. Edges that intersect scan line y are likely to intersect y+1 x changes predictably from scan line y to y+1 The following two data structures can be used by an efficient scan an- conversion algorithm: Edge Table and Active Edge List (AEL). 17 Procedure for Establishing An Edge Table Traverse edges Eliminate horizontal edges, e.g., edge e7 If not local extremum (minimum or maximum),, shorten upper vertex, e.g., upper vertex of edges e2 and e5 ( 比較三個連續點加以判斷 ) Add edge to linked-list list for the scan line according to the lower vertex (e.g., e2-e3, e3, e4-e5, e5, e1, e6),, and store the following data: y_upper: the last scan line to consider for an edge, e.g. 8 for edge e1 x_lower: the starting x coordinate for an edge, e.g. 9 for edge e1 1/m (= x/ x/ y= y= x) x): : will be used for incrementing x (compute before shortening) 18 y_upper, x_lower, 1/m

10 Active Edge List (AEL) & Scan Conversion Algorithm The AEL is a linked list of active edges on the current scan line, y. Each active edge has the following information: y_upper: the last scan line to consider x: edge's intersection with current y 1/m: for incrementing x The active edges are kept sorted by x y_upper, x_lower, 1/m Scan Conversion Algorithm Do for each scan line { Add edges in edge table to AEL; If (AEL!= NULL) { Sort AEL by x; Fill pixels between edge pairs; Delete finished edges; Update each edge's x; y_upper, x_lower, 1/m 0 wcpt2 pt[]={ 0.6, 0.8, 0.9, 0.5, 0.9, 0.1, 0.5, 0.5, 0.1, 0.2, 0.2, 0.7, 0.4, 0.8, ; 1

11 Assignment pts[0].x = 0.25*w; pts[1].x = 0.75*w; pts[2].x = 0.75 *w; pts[0].y = 0.25*h; pts[1].y = 0.75*h; pts[2].y = 0.25*h; pts[3].x = 0.25*w; pts[3].y = 0.75* h; 21 Struct A struct for defining a point in device coordinates typedef struct { int x; int y; dcpt; A struct for defining an edge typedef struct tedge { int yupper; float xintersect; float dxperscan; // dx/dy = 1/m struct tedge* next; Edge; data Edge next dcpt Int pts[7]; winwidth, winheight; // width and height of a window 22

12 Main Function: ScanFill void scanfill (int nop, dcpt * pts) {//cnt{ /cnt=7 Edge* active; int i, scan; Edge** edges = (Edge **) malloc ( winheight * sizeof (Edge*) ); /* pointer 'edges' will point to a pointer 'edges[i]', I=0,,, h */ 0 1 for (i=0; i<winheighti <winheight; ; i++) { edges[i] = (Edge *) malloc (sizeof (Edge)); edges[i]->next = NULL; buildedgelist (cnt,, pts, edges); active = (Edge *) malloc ( sizeof (Edge) ); active->next = NULL; for (scan=0; scan<winheight <winheight; ; scan++) { buildactivelist (scan, active, edges); if (active->next) { fillscan (scan, active); updateactivelist (scan, active); resortactivelist (active); 23 edges[7] edges Edge y_upper, x_lower, 1/m, next Build Edge List void buildedgelist (int nop, dcpt * pts, Edge * edges[]) { Edge* edge; Prev v1 dcpt v1, v2; v1 v2(i=0) int i, yprev = pts[cnt - 2].y; 6 0 Prev v1.x = pts[cnt [cnt-1].x; 5 v1.y = pts[cnt [cnt-1].y; 3 v2(i=1) for (i=0; i<cnti <cnt; ; i++) { 1 v1 v2 = pts[i];//check edge 6_0 if (v1.y!= v2.y) {//nonhorizontal{ /nonhorizontal line 4 2 edge = (Edge*) malloc (sizeof (Edge)); if (v1.y < v2.y) {//up{ //up-going edge v2(i=2) makeedgerec (v1, v2, ynext (i, nop,, pts),, edge, edges); else {//down{ //down-going edge Prev makeedgerec (v2, v1, yprev,, edge, edges); next v2(i=6) Next 6 yprev = v1.y; v2(i=5) 5 0 v1 = v2; 3 1 //end for v2(i=3) v1 4 2 Next 24 v1

13 Make Edge Record void makeedgerec(dcpt lower, dcpt upper, int ycomp,, Edge * edge, Edge * edges[]) { edge->dxperscan = (float) (upper.x - lower.x) / (upper.y - lower.y); edge->xintersect = lower.x; if (upper.y < ycomp) ) { edge->yupper = upper.y - 1;//shorten upper vertex else { edge->yupper = upper.y; upper comp upper insertedge (edges[lower.y], edge); //insert an edge into the list for the scan line passing through P0 Edge edges[7] comp lower lower 25 edges y_upper, x_lower, 1/m Inserts Edge Into List void insertedge (Edge* list, Edge * edge) { Edge* p; Edge* q = list; //insert an edge and sort p = q->next; q while (p!= NULL) { if (edge->xintersect < p->xintersectp >xintersect) ) { p = NULL; q=list else { q = p; p = p->next; p //end while edge->next = q->next; q q->next = edge; upper 1. p=q->next data next data next comp lower 3. q->next=edge 2. edge->next=q->next data next 26 y_upper, x_lower, 1/m

14 Insert a Node (General) list data next data next q=list 1. p=q->next data next data next // // 記住記住 q 原來所指之節點 p = q->next; // // 使欲插入之節點 edge edge 指向 q 原來所指之節點 edge->next = q->next; // // 使 q 指向插入之節點 q->next = edge; edge; 3. q->next=edgeq data next 2. edge->next=q >next=q->next edge 27 Insert a Node & Sort q=list data next data next data list next data p=q->next edge next q=p data next p=p->next data next data next p = q->next; q while (p!= NULL) { if (edge->xintersect< < p->xintersect) ) { p = NULL;//force to leave the loop else { q = p; p = p->next;//shift edge->next = q->next; q q->next = edge; 28 data next edge

15 Fill Polygon for (scan=0; scan<winheight <winheight; ; scan++) { buildactivelist (scan, active, edges); if (active->next) { fillscan (scan, active); updateactivelist (scan, active); resortactivelist (active); edges[7] Edge active edges y_upper, x_lower, 1/m 29 Build Active List void buildactivelist (int scan, Edge * active, Edge * edges[]) { Edge * p, * q; p = edges[scan]->next; while (p) { q = p->next; p insertedge (active, p);//add edge p into active list p = q; Edge edges[7] 30 edges y_upper, x_lower, 1/m

16 Fill A Scan Line void fillscan (int scan, Edge * active) { Edge * p1, * p2; int i; p1 = active->next; while (p1) { p2 = p1->next; for (i=p1->xintersect >xintersect; ; i<p2->xintersect >xintersect; ; i++) Draw_Point ((int( (int)) i, scan); p1 = p2->next; edges[7] Edge 31 edges y_upper, x_lower, 1/m 32 Update Active List Delete completed edges. Update 'xintersect' ' field for others void updateactivelist (int scan, Edge * active) { Edge * q = active, * p = active->next; while (p) if (scan >= p->yupperp >yupper) ) { p = p->next; p deleteafter (q); else { p->xintersect += p->dxperscanp >dxperscan; q = p; p = p->next; p //end if scan void deleteafter (Edge * q) { Edge* p = q->next; q->next = p->next; free (p); edges[7] edges q 2. q->next=p->next data next data next data next 1. p=q->next Delete a node Edge y_upper, x_lower, 1/m

17 Resort Active List void resortactivelist (Edge * active) { Edge * q, * p = active->next; active->next = NULL; while (p) { q = p->next; p insertedge (active, p); p = q; edges[7] Edge 33 edges y_upper, x_lower, 1/m Polygon Clipping The Sutherland-Hodgman algorithm can be used to clip any polygon (convex( or concave) ) against any convex clipping polygon. The algorithm clips against one edge at a time, producing a new vertex list each time. The following figure assumes the most common case, a rectangular clipping window. 34 Polyline Clipping

18 Pseudo Codes for the Algorithm The algorithm can be summarized as follows: for each side of clipping window for each edge of polygon output points based upon the following table 35 Example 36

19 Using Outcodes for Trivial Accept and Reject In many cases, two trivial tests can be used to quickly determine whether a polygon is completely inside or outside the viewing window. This then allows us to skip the above clipping procedure. The trivial tests require first computing outcodes. A vertex outcode consists of four bits: TBRL, where: T is set if y > top, B is set if y < bottom, R is set if x > right, and L is set if x < left. T L Trivial accept: all vertices are inside (all outcodes are 0000) Trivial reject: all vertices are outside with respect to any given side (bitwise AND is not 0000) 37 Main Procedures & Varibles #define N_EDGE 4 typedef enum { Left, Right, Bottom, Top Edge;// 列舉, Left=0, Right=1, #define N_PTS 6 wcpt2 pts[n_pts] = { 60, 20, 375, 80, 280, 280, 100, 280, 100, 100, 60, ; dcpt winmin = { 50, 50 ; dcpt winmax = { 350, 250 ; (100,280) (280,280) (350,250) int i, npts; wcpt2 clippedpts[256]; (375,80) void render(void) { (50,50) (60,20) /* Clip the polygon against the window, returning 'clippedpts' ' */ npts = clippolygon (winmin, winmax, N_PTS, pts, clippedpts); // end function 38

20 Function: inside Input a point p and an edge b to determine whether it is inside or not Ex: inside (p1, b, wmin, wmax) int inside (wcpt2 p,, Edge b, dcpt wmin, dcpt wmax) ) { switch (b)( ) { case Left: (wmax.x, wmax.y) if (p.x( < wmin.x) return (FALSE); break; case Right: if (p.x( > wmax.x) return (FALSE); break; case Bottom: if (p.y( < wmin.y) return (FALSE); (wmin.x, wmin.y) break; case Top: if (p.y( > wmax.y) return (FALSE); break; // end switch return (TRUE); 39// end function Function: cross Given: two points of a line segment and an clipping edge Return: whether the line cross an edge Ex: cross (p, s[b], b, wmin, wmax) int cross (wcpt2 p1,, wcpt2 p2,, Edge b, dcpt wmin, dcpt wmax) ) { if (inside( (p1, b, wmin, wmax) ) == inside (p2, b, wmin, wmax)) return (FALSE); //p1 and p2 are both inside or outside else return (TRUE); //p1 and p2 are on the different side of edge b // end function 40

21 Function: intersect EX: ipt = intersect (p, s[b], b, wmin, wmax); wcpt2 intersect (wcpt2 p1, wcpt2 p2, Edge b, dcpt wmin, dcpt wmax) ) { wcpt2 ipt;//intersection point, 交點 float m;//slope, 斜率 if (p1.x!= p2.x) m = (p1.y - p2.y) / (p1.x - p2.x); // 線段不平行 y 軸時才求斜率 switch (b) { case Left: ipt.x = wmin.x; ipt.y = p2.y + (wmin.x - p2.x) * m; break; case Right: ipt.x = wmax.x; ipt.y = p2.y + (wmax.x - p2.x) * m; break; case Bottom: ipt.y = wmin.y; if (p1.x!= p2.x) ipt.x = p2.x + (wmin.y - p2.y) / m; else ipt.x = p2.x; break; case Top: ipt.y = wmax.y; if (p1.x!= p2.x) ipt.x = p2.x + (wmax.y - p2.y) / m; else ipt.x = p2.x; break; (wmax.x, wmax.y) P, p1 return (ipt); );// 傳回交點之座標 // end function S, p2 41 (wmin.x, wmin.y) Function: clippolygon int clippolygon (dcpt wmin, dcpt wmax, int n,, wcpt2* pin,, wcpt2* pout) ) { // 'first' first' ' holds pointer to first point processed against a clip edge // 's'' ' holds most recent point processed against an edge wcpt2* first[n_edge] = { 0, 0, 0, 0 ; wcpt2 s[n_edge]; int i, cnt = 0; for (i=0; i<n; ; i++) clippoint (pin[i], Left, wmin, wmax, pout, &cnt, first, s); closeclip (wmin, wmax, pout, &cnt, first, s); return (cnt); // end function (100,280) (280,280) (350,250) 42 (50,50) (60,20) (375,80)

22 Function: clippoint Ex: for (i=0; i<n; ; i++) clippoint (pin[i], Left, wmin, wmax, pout, &cnt, first, s); void clippoint (wcpt2 p, Edge b, dcpt wmin, dcpt wmax,, wcpt2* pout, int* cnt,, wcpt2* first[], wcpt2* s) { //may replace wcpt2* first[] by wcpt2** first wcpt2 ipt; Enter with input vertex P if (!first[b]) { first[b] ] = &p; //first[b] is also a pointer, so first is a pointer s pointer else { No Yes First Point? if (cross( (p, s[b], b, wmin, wmax)) { ipt = intersect (p, s[b], b, wmin, wmax); Does line SP No if (b < Top) P"S cross a plane? clippoint (ipt, b+1, wmin, wmax, pout, cnt,, first, s); else Yes { pout[*cnt *cnt]] = ipt; ; (*cnt( *cnt)++; Compute intersection, I, // end if (cross ) of SP and the plane P"S // end if (!first ) P"F"S s[b] ] = p; if (inside( (p, b, wmin, wmax)) { if (b < Top) clippoint (p, b+1, wmin, wmax, pout, cnt,, first, s); else { pout[*cnt *cnt]] = p; (*cnt( *cnt)++; // end if (inside ) // end function 43 Debug Data (100,280) (280,280) (350,250) I (50,50) F,S(60,20) Output I P(375,80) No Is S on visible side of plane? Yes Output S Exit Function: closeclip void closeclip (dcpt wmin, dcpt wmax, wcpt2* pout, int* cnt, wcpt2* first[], wcpt2* s) { wcpt2 i; Edge b; No Close polygon entry Was there any output? for (b = Left; b <= Top; b++) { if (cross (s[b], *first[b], b, wmin, wmax)) { i = intersect (s[b], *first[b], b, wmin, wmax); No if (b < Top) clippoint (i, b+1, wmin, wmax, Reset pout, cnt,, first, s); first flag else { pout[*cnt *cnt]] = i; (*cnt( *cnt)++; Close // end if (b<top) next stage // end if cross() // end for b // end function Exit Yes Does link SF cross plane? Compute intersection, I, of edge SF and Yes the the plane Output I (100,280) (280,280) (350,250) (375,80) 44 (50,50) (60,20)

23 Debug Start!!! i=0, call clippoint... clipping edge=0 first=[ 60.0, 20.0], s=[ 60.0, 20.0] clipping edge=1 first=[ 60.0, 20.0], s=[ 60.0, 20.0] clipping edge=2 first=[ 60.0, 20.0], s=[ 60.0, 20.0] i=1, call clippoint... clipping edge=0 first=[375.0, 80.0], s=[375.0, 80.0] clipping edge=1 clipping edge=2 clipping edge=3 first=[217.5, 50.0], s=[217.5, 50.0] first=[350.0, 75.2], s=[350.0, 75.2] clipping edge=3 first=[350.0, 75.2], s=[350.0, 75.2] first=[375.0, 80.0], s=[375.0, 80.0] i=2, call clippoint... clipping edge=0 first=[280.0, 280.0], s=[280.0, 280.0] clipping edge=1 clipping edge=2 first=[350.0, 132.6], s=[350.0, 132.6] clipping edge=3 first=[350.0, 132.6], s=[350.0, 132.6] first=[280.0, 280.0], s=[280.0, 280.0] clipping edge=2 first=[280.0, 280.0], s=[280.0, 280.0] clipping edge=3 first=[280.0, 280.0], s=[280.0, 280.0] i=3, call clippoint... clipping edge=0 first=[100.0, 280.0], s=[100.0, 280.0] clipping edge=1 first=[100.0, 280.0], s=[100.0, 280.0] clipping edge=2 first=[100.0, 280.0], s=[100.0, 280.0] clipping edge=3 first=[100.0, 280.0], s=[100.0, 280.0] i=4, call clippoint... clipping edge=0 first=[100.0, 100.0], s=[100.0, 100.0] clipping edge=1 first=[100.0, 100.0], s=[100.0, 100.0] clipping edge=2 first=[100.0, 100.0], s=[100.0, 100.0] clipping edge=3 first=[100.0, 100.0], s=[100.0, 100.0] i=5, call clippoint... clipping edge=0 first=[ 60.0, 20.0], s=[ 60.0, 20.0] clipping edge=1 first=[ 60.0, 20.0], s=[ 60.0, 20.0] clipping edge=2 clipping edge=3 first=[ 75.0, 50.0], s=[ 75.0, 50.0] first=[ 60.0, 20.0], s=[ 60.0, 20.0] clipping edge=1 first=[ 0.0, 0.0], s=[ 50.0, 20.0] clipping edge=2 first=[ 0.0, 0.0], s=[ 50.0, 20.0] (50,50) (100,280) (60,20) (280,280) (350,250) (375,80) 45

Rendering. A simple X program to illustrate rendering

Rendering. A simple X program to illustrate rendering Rendering A simple X program to illustrate rendering The programs in this directory provide a simple x based application for us to develop some graphics routines. Please notice the following: All points

More information

Rendering. A simple X program to illustrate rendering

Rendering. A simple X program to illustrate rendering Rendering A simple X program to illustrate rendering The programs in this directory provide a simple x based application for us to develop some graphics routines. Please notice the following: All points

More information

Graphics System. Processor. Output Display. Input Devices. Frame Buffer. Memory. Array of pixels. Resolution: # of pixels Depth: # of bits/pixel

Graphics System. Processor. Output Display. Input Devices. Frame Buffer. Memory. Array of pixels. Resolution: # of pixels Depth: # of bits/pixel Graphics System Input Devices Processor Memory Frame Buffer Output Display Array of pixels Resolution: # of pixels Depth: # of bits/pixel Input Devices Physical Devices: Keyboard, Mouse, Tablet, etc. Logical

More information

Polygon Filling. Can write frame buffer one word at time rather than one bit. 2/3/2000 CS 4/57101 Lecture 6 1

Polygon Filling. Can write frame buffer one word at time rather than one bit. 2/3/2000 CS 4/57101 Lecture 6 1 Polygon Filling 2 parts to task which pixels to fill what to fill them with First consider filling unclipped primitives with solid color Which pixels to fill consider scan lines that intersect primitive

More information

Chapter 8: Implementation- Clipping and Rasterization

Chapter 8: Implementation- Clipping and Rasterization Chapter 8: Implementation- Clipping and Rasterization Clipping Fundamentals Cohen-Sutherland Parametric Polygons Circles and Curves Text Basic Concepts: The purpose of clipping is to remove objects or

More information

Rasterization: Geometric Primitives

Rasterization: Geometric Primitives Rasterization: Geometric Primitives Outline Rasterizing lines Rasterizing polygons 1 Rasterization: What is it? How to go from real numbers of geometric primitives vertices to integer coordinates of pixels

More information

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives. D Graphics Primitives Eye sees Displays - CRT/LCD Frame buffer - Addressable pixel array (D) Graphics processor s main function is to map application model (D) by projection on to D primitives: points,

More information

CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines. Emmanuel Agu

CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines. Emmanuel Agu CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines Emmanuel Agu 2D Graphics Pipeline Clipping Object World Coordinates Applying world window Object subset window to viewport mapping

More information

1 Introduction to Graphics

1 Introduction to Graphics 1 1.1 Raster Displays The screen is represented by a 2D array of locations called pixels. Zooming in on an image made up of pixels The convention in these notes will follow that of OpenGL, placing the

More information

Computer Graphics. - Rasterization - Philipp Slusallek

Computer Graphics. - Rasterization - Philipp Slusallek Computer Graphics - Rasterization - Philipp Slusallek Rasterization Definition Given some geometry (point, 2D line, circle, triangle, polygon, ), specify which pixels of a raster display each primitive

More information

COMP371 COMPUTER GRAPHICS

COMP371 COMPUTER GRAPHICS COMP371 COMPUTER GRAPHICS LECTURE 14 RASTERIZATION 1 Lecture Overview Review of last class Line Scan conversion Polygon Scan conversion Antialiasing 2 Rasterization The raster display is a matrix of picture

More information

Scan Converting Lines

Scan Converting Lines Scan Conversion 1 Scan Converting Lines Line Drawing Draw a line on a raster screen between two points What s wrong with the statement of the problem? it doesn t say anything about which points are allowed

More information

Rasterization, or What is glbegin(gl_lines) really doing?

Rasterization, or What is glbegin(gl_lines) really doing? Rasterization, or What is glbegin(gl_lines) really doing? Course web page: http://goo.gl/eb3aa February 23, 2012 Lecture 4 Outline Rasterizing lines DDA/parametric algorithm Midpoint/Bresenham s algorithm

More information

From Ver(ces to Fragments: Rasteriza(on

From Ver(ces to Fragments: Rasteriza(on From Ver(ces to Fragments: Rasteriza(on From Ver(ces to Fragments 3D vertices vertex shader rasterizer fragment shader final pixels 2D screen fragments l determine fragments to be covered l interpolate

More information

CS 543: Computer Graphics. Rasterization

CS 543: Computer Graphics. Rasterization CS 543: Computer Graphics Rasterization Robert W. Lindeman Associate Professor Interactive Media & Game Development Department of Computer Science Worcester Polytechnic Institute gogo@wpi.edu (with lots

More information

CS 130. Scan Conversion. Raster Graphics

CS 130. Scan Conversion. Raster Graphics CS 130 Scan Conversion Raster Graphics 2 1 Image Formation Computer graphics forms images, generally two dimensional, using processes analogous to physical imaging systems like: - Cameras - Human visual

More information

2D Image Synthesis. 2D image synthesis. Raster graphics systems. Modeling transformation. Vectorization. u x u y 0. o x o y 1

2D Image Synthesis. 2D image synthesis. Raster graphics systems. Modeling transformation. Vectorization. u x u y 0. o x o y 1 General scheme of a 2D CG application 2D Image Synthesis Balázs Csébfalvi modeling image synthesis Virtual world model world defined in a 2D plane Department of Control Engineering and Information Technology

More information

Rasteriza2on and Clipping

Rasteriza2on and Clipping Overview Scan conversion Computer Graphics Rasterizaon and Clipping Polygon filling Clipping in D Aleksandra Pizurica Raster Display PIEL (picture element) RASTER (a rectangular array of points or dots)

More information

Tópicos de Computação Gráfica Topics in Computer Graphics 10509: Doutoramento em Engenharia Informática. Chap. 2 Rasterization.

Tópicos de Computação Gráfica Topics in Computer Graphics 10509: Doutoramento em Engenharia Informática. Chap. 2 Rasterization. Tópicos de Computação Gráfica Topics in Computer Graphics 10509: Doutoramento em Engenharia Informática Chap. 2 Rasterization Rasterization Outline : Raster display technology. Basic concepts: pixel, resolution,

More information

Announcements. Midterms graded back at the end of class Help session on Assignment 3 for last ~20 minutes of class. Computer Graphics

Announcements. Midterms graded back at the end of class Help session on Assignment 3 for last ~20 minutes of class. Computer Graphics Announcements Midterms graded back at the end of class Help session on Assignment 3 for last ~20 minutes of class 1 Scan Conversion Overview of Rendering Scan Conversion Drawing Lines Drawing Polygons

More information

Rasterization. CS4620/5620: Lecture 12. Announcements. Turn in HW 1. PPA 1 out. Friday lecture. History of graphics PPA 1 in 4621.

Rasterization. CS4620/5620: Lecture 12. Announcements. Turn in HW 1. PPA 1 out. Friday lecture. History of graphics PPA 1 in 4621. CS4620/5620: Lecture 12 Rasterization 1 Announcements Turn in HW 1 PPA 1 out Friday lecture History of graphics PPA 1 in 4621 2 The graphics pipeline The standard approach to object-order graphics Many

More information

Scan Conversion. Lines and Circles

Scan Conversion. Lines and Circles Scan Conversion Lines and Circles (Chapter 3 in Foley & Van Dam) 2D Line Implicit representation: αx + βy + γ = 0 Explicit representation: y y = mx+ B m= x Parametric representation: x P= y P = t y P +

More information

Scan Converting Circles

Scan Converting Circles Scan Conversion Algorithms CS 460 Computer Graphics Professor Richard Eckert Circles Ellipses and Other 2-D Curves Text February 16, 2004 Scan Converting Circles Given: Center: (h,k) Radius: r Equation:

More information

Scan Conversion. Drawing Lines Drawing Circles

Scan Conversion. Drawing Lines Drawing Circles Scan Conversion Drawing Lines Drawing Circles 1 How to Draw This? 2 Start From Simple How to draw a line: y(x) = mx + b? 3 Scan Conversion, a.k.a. Rasterization Ideal Picture Raster Representation Scan

More information

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored. From Vertices to Fragments: Rasterization Reading Assignment: Chapter 7 Frame Buffer Special memory where pixel colors are stored. System Bus CPU Main Memory Graphics Card -- Graphics Processing Unit (GPU)

More information

Computer Graphics (CS 543) Lecture 10: Rasterization and Antialiasing

Computer Graphics (CS 543) Lecture 10: Rasterization and Antialiasing Computer Graphics (CS 543) Lecture 10: Rasterization and Antialiasing Prof Emmanuel Agu Computer Science Dept. Worcester Polytechnic Institute (WPI) Recall: Rasterization Rasterization (scan conversion)

More information

Clipping and Scan Conversion

Clipping and Scan Conversion 15-462 Computer Graphics I Lecture 14 Clipping and Scan Conversion Line Clipping Polygon Clipping Clipping in Three Dimensions Scan Conversion (Rasterization) [Angel 7.3-7.6, 7.8-7.9] March 19, 2002 Frank

More information

Raster Displays and Scan Conversion. Computer Graphics, CSCD18 Fall 2008 Instructor: Leonid Sigal

Raster Displays and Scan Conversion. Computer Graphics, CSCD18 Fall 2008 Instructor: Leonid Sigal Raster Displays and Scan Conversion Computer Graphics, CSCD18 Fall 28 Instructor: Leonid Sigal Rater Displays Screen is represented by 2D array of locations called piels y Rater Displays Screen is represented

More information

Line Drawing. Foundations of Computer Graphics Torsten Möller

Line Drawing. Foundations of Computer Graphics Torsten Möller Line Drawing Foundations of Computer Graphics Torsten Möller Rendering Pipeline Hardware Modelling Transform Visibility Illumination + Shading Perception, Interaction Color Texture/ Realism Reading Angel

More information

Rasterization. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 16

Rasterization. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 16 Rasterization CS 4620 Lecture 16 1 Announcements A3 due on Thu Will send mail about grading once finalized 2 Pipeline overview you are here APPLICATION COMMAND STREAM 3D transformations; shading VERTEX

More information

Topic #1: Rasterization (Scan Conversion)

Topic #1: Rasterization (Scan Conversion) Topic #1: Rasterization (Scan Conversion) We will generally model objects with geometric primitives points, lines, and polygons For display, we need to convert them to pixels for points it s obvious but

More information

Realtime 3D Computer Graphics Virtual Reality

Realtime 3D Computer Graphics Virtual Reality Realtime 3D Computer Graphics Virtual Reality From Vertices to Fragments Overview Overall goal recapitulation: Input: World description, e.g., set of vertices and states for objects, attributes, camera,

More information

CPSC / Scan Conversion

CPSC / Scan Conversion CPSC 599.64 / 601.64 Computer Screens: Raster Displays pixel rasters (usually) square pixels in rectangular raster evenly cover the image problem no such things such as lines, circles, etc. scan conversion

More information

Rasterization. COMP 575/770 Spring 2013

Rasterization. COMP 575/770 Spring 2013 Rasterization COMP 575/770 Spring 2013 The Rasterization Pipeline you are here APPLICATION COMMAND STREAM 3D transformations; shading VERTEX PROCESSING TRANSFORMED GEOMETRY conversion of primitives to

More information

CS Rasterization. Junqiao Zhao 赵君峤

CS Rasterization. Junqiao Zhao 赵君峤 CS10101001 Rasterization Junqiao Zhao 赵君峤 Department of Computer Science and Technology College of Electronics and Information Engineering Tongji University Vector Graphics Algebraic equations describe

More information

Computer Graphics D Graphics Algorithms

Computer Graphics D Graphics Algorithms ! Computer Graphics 2014! 2. 2D Graphics Algorithms Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2014-09-26! Screen Nikon D40 Sensors 3 Rasterization - The task of displaying a world modeled

More information

Einführung in Visual Computing

Einführung in Visual Computing Einführung in Visual Computing 186.822 Rasterization Werner Purgathofer Rasterization in the Rendering Pipeline scene objects in object space transformed vertices in clip space scene in normalized device

More information

Line Drawing Week 6, Lecture 9

Line Drawing Week 6, Lecture 9 CS 536 Computer Graphics Line Drawing Week 6, Lecture 9 David Breen, William Regli and axim Peysakhov Department of Computer Science Drexel University Outline Line drawing Digital differential analyzer

More information

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU FROM VERTICES TO FRAGMENTS Lecture 5 Comp3080 Computer Graphics HKBU OBJECTIVES Introduce basic implementation strategies Clipping Scan conversion OCTOBER 9, 2011 2 OVERVIEW At end of the geometric pipeline,

More information

Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller

Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller Line Drawing Introduction to Computer Graphics Torsten Möller / Mike Phillips Rendering Pipeline Hardware Modelling Transform Visibility Illumination + Shading Perception, Color Interaction Texture/ Realism

More information

Graphics (Output) Primitives. Chapters 3 & 4

Graphics (Output) Primitives. Chapters 3 & 4 Graphics (Output) Primitives Chapters 3 & 4 Graphic Output and Input Pipeline Scan conversion converts primitives such as lines, circles, etc. into pixel values geometric description a finite scene area

More information

Pipeline and Rasterization. COMP770 Fall 2011

Pipeline and Rasterization. COMP770 Fall 2011 Pipeline and Rasterization COMP770 Fall 2011 1 The graphics pipeline The standard approach to object-order graphics Many versions exist software, e.g. Pixar s REYES architecture many options for quality

More information

EF432. Introduction to spagetti and meatballs

EF432. Introduction to spagetti and meatballs EF432 Introduction to spagetti and meatballs CSC 418/2504: Computer Graphics Course web site (includes course information sheet): http://www.dgp.toronto.edu/~karan/courses/418/fall2015 Instructor: Karan

More information

Points and lines. x x 1 + y 1. y = mx + b

Points and lines. x x 1 + y 1. y = mx + b Points and lines Point is the fundamental element of the picture representation. It is nothing but the position in a plan defined as either pairs or triplets of number depending on whether the data are

More information

Digital Differential Analyzer Bresenhams Line Drawing Algorithm

Digital Differential Analyzer Bresenhams Line Drawing Algorithm Bresenham s Line Generation The Bresenham algorithm is another incremental scan conversion algorithm. The big advantage of this algorithm is that, it uses only integer calculations. Difference Between

More information

CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE

CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE CS 450: COMPUTER GRAPHICS REVIEW: DRAWING LINES AND CIRCLES SPRING 2015 DR. MICHAEL J. REALE DRAWING PRIMITIVES: LEGACY VS. NEW Legacy: specify primitive in glbegin() glbegin(gl_points); glvertex3f(1,5,0);

More information

Rasterization. CS4620 Lecture 13

Rasterization. CS4620 Lecture 13 Rasterization CS4620 Lecture 13 2014 Steve Marschner 1 The graphics pipeline The standard approach to object-order graphics Many versions exist software, e.g. Pixar s REYES architecture many options for

More information

Chapter - 2: Geometry and Line Generations

Chapter - 2: Geometry and Line Generations Chapter - 2: Geometry and Line Generations In Computer graphics, various application ranges in different areas like entertainment to scientific image processing. In defining this all application mathematics

More information

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into 2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into the viewport of the current application window. A pixel

More information

Computer Graphics D Graphics Algorithms

Computer Graphics D Graphics Algorithms Computer Graphics 2015 2. 2D Graphics Algorithms Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2015-09-21 Screen - Linear Structure Nikon D40 Sensors 3 RGBW Camera Sensor RGBW Camera Sensor

More information

Two-Dimensional Viewing. Chapter 6

Two-Dimensional Viewing. Chapter 6 Two-Dimensional Viewing Chapter 6 Viewing Pipeline Two-Dimensional Viewing Two dimensional viewing transformation From world coordinate scene description to device (screen) coordinates Normalization and

More information

Line Drawing Algorithms

Line Drawing Algorithms Chapter 3 " Line Drawing Algorithms ~: Learning Objectives :~ The objectives of this chapter are to acquaint you with: + Scan conversion line drawing + Bresenham s line drawing + Drawing bar chart + Problems

More information

The graphics pipeline. Pipeline and Rasterization. Primitives. Pipeline

The graphics pipeline. Pipeline and Rasterization. Primitives. Pipeline The graphics pipeline Pipeline and Rasterization CS4620 Lecture 9 The standard approach to object-order graphics Many versions exist software, e.g. Pixar s REYES architecture many options for quality and

More information

Last class. A vertex (w x, w y, w z, w) - clipping is in the - windowing and viewport normalized view volume if: - scan conversion/ rasterization

Last class. A vertex (w x, w y, w z, w) - clipping is in the - windowing and viewport normalized view volume if: - scan conversion/ rasterization Lecture 6 Last class Last lecture (clip coordinates): A vertex (w x, w y, w z, w) - clipping is in the - windowing and viewport normalized view volume if: - scan conversion/ rasterization normalized view

More information

Fall CSCI 420: Computer Graphics. 7.1 Rasterization. Hao Li.

Fall CSCI 420: Computer Graphics. 7.1 Rasterization. Hao Li. Fall 2015 CSCI 420: Computer Graphics 7.1 Rasterization Hao Li http://cs420.hao-li.com 1 Rendering Pipeline 2 Outline Scan Conversion for Lines Scan Conversion for Polygons Antialiasing 3 Rasterization

More information

Output Primitives Lecture: 3. Lecture 3. Output Primitives. Assuming we have a raster display, a picture is completely specified by:

Output Primitives Lecture: 3. Lecture 3. Output Primitives. Assuming we have a raster display, a picture is completely specified by: Lecture 3 Output Primitives Assuming we have a raster display, a picture is completely specified by: - A set of intensities for the pixel positions in the display. - A set of complex objects, such as trees

More information

Topics. From vertices to fragments

Topics. From vertices to fragments Topics From vertices to fragments From Vertices to Fragments Assign a color to every pixel Pass every object through the system Required tasks: Modeling Geometric processing Rasterization Fragment processing

More information

Surface shading: lights and rasterization. Computer Graphics CSE 167 Lecture 6

Surface shading: lights and rasterization. Computer Graphics CSE 167 Lecture 6 Surface shading: lights and rasterization Computer Graphics CSE 167 Lecture 6 CSE 167: Computer Graphics Surface shading Materials Lights Rasterization 2 Scene data Rendering pipeline Modeling and viewing

More information

VIEW VOLUME & CLPPING

VIEW VOLUME & CLPPING VIEW VOLUME & CLPPING The Stage of View Volume Clipping Plane Equations Clipping a 3-Vertices Facet with an Arbitrary Plane Line-plane Intersection & Coding OpenGL calls for Setting Clipping Planes Clipping

More information

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005 INSTITUTIONEN FÖR SYSTEMTEKNIK LULEÅ TEKNISKA UNIVERSITET Renderer Implementation: Basics and Clipping David Carr Virtual Environments, Fundamentals Spring 2005 Feb-28-05 SMM009, Basics and Clipping 1

More information

Computer Graphics 7 - Rasterisation

Computer Graphics 7 - Rasterisation Computer Graphics 7 - Rasterisation Tom Thorne Slides courtesy of Taku Komura www.inf.ed.ac.uk/teaching/courses/cg Overview Line rasterisation Polygon rasterisation Mean value coordinates Decomposing polygons

More information

CSCI 420 Computer Graphics Lecture 14. Rasterization. Scan Conversion Antialiasing [Angel Ch. 6] Jernej Barbic University of Southern California

CSCI 420 Computer Graphics Lecture 14. Rasterization. Scan Conversion Antialiasing [Angel Ch. 6] Jernej Barbic University of Southern California CSCI 420 Computer Graphics Lecture 14 Rasterization Scan Conversion Antialiasing [Angel Ch. 6] Jernej Barbic University of Southern California 1 Rasterization (scan conversion) Final step in pipeline:

More information

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines COMP30019 Graphics and Interaction Scan Converting Polygons and Lines Department of Computer Science and Software Engineering The Lecture outline Introduction Scan conversion Scan-line algorithm Edge coherence

More information

Incremental Form. Idea. More efficient if we look at d k, the value of the decision variable at x = k

Incremental Form. Idea. More efficient if we look at d k, the value of the decision variable at x = k Idea 1 m 0 candidates last pixel Note that line could have passed through any part of this pixel Decision variable: d = x(a-b) d is an integer d < 0 use upper pixel d > 0 use lower pixel Incremental Form

More information

CS602 Midterm Subjective Solved with Reference By WELL WISHER (Aqua Leo)

CS602 Midterm Subjective Solved with Reference By WELL WISHER (Aqua Leo) CS602 Midterm Subjective Solved with Reference By WELL WISHER (Aqua Leo) www.vucybarien.com Question No: 1 What are the two focusing methods in CRT? Explain briefly. Page no : 26 1. Electrostatic focusing

More information

Painter s HSR Algorithm

Painter s HSR Algorithm Painter s HSR Algorithm Render polygons farthest to nearest Similar to painter layers oil paint Viewer sees B behind A Render B then A Depth Sort Requires sorting polygons (based on depth) O(n log n) complexity

More information

Computer Graphics and GPGPU Programming

Computer Graphics and GPGPU Programming Computer Graphics and GPGPU Programming Donato D Ambrosio Department of Mathematics and Computer Science and Center of Excellence for High Performace Computing Cubo 22B, University of Calabria, Rende 87036,

More information

Rasterization. Rasterization (scan conversion) Digital Differential Analyzer (DDA) Rasterizing a line. Digital Differential Analyzer (DDA)

Rasterization. Rasterization (scan conversion) Digital Differential Analyzer (DDA) Rasterizing a line. Digital Differential Analyzer (DDA) CSCI 420 Computer Graphics Lecture 14 Rasterization Jernej Barbic University of Southern California Scan Conversion Antialiasing [Angel Ch. 6] Rasterization (scan conversion) Final step in pipeline: rasterization

More information

Computer Graphics - Week 6

Computer Graphics - Week 6 Computer Graphics - Week 6 Bengt-Olaf Schneider IBM T.J. Watson Research Center Questions about Last Week? Questions about Assignment? Comments about submission Deadline is Friday, 2/26 at 5:30 pm Standard

More information

EF432. Introduction to spagetti and meatballs

EF432. Introduction to spagetti and meatballs EF432 Introduction to spagetti and meatballs CSC 418/2504: Computer Graphics Course web site (includes course information sheet): http://www.dgp.toronto.edu/~karan/courses/418/ Instructors: L2501, T 6-8pm

More information

Rendering approaches. 1.image-oriented. 2.object-oriented. foreach pixel... 3D rendering pipeline. foreach object...

Rendering approaches. 1.image-oriented. 2.object-oriented. foreach pixel... 3D rendering pipeline. foreach object... Rendering approaches 1.image-oriented foreach pixel... 2.object-oriented foreach object... geometry 3D rendering pipeline image 3D graphics pipeline Vertices Vertex processor Clipper and primitive assembler

More information

RASTERIZING POLYGONS IN IMAGE SPACE

RASTERIZING POLYGONS IN IMAGE SPACE On-Line Computer Graphics Notes RASTERIZING POLYGONS IN IMAGE SPACE Kenneth I. Joy Visualization and Graphics Research Group Department of Computer Science University of California, Davis A fundamental

More information

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Clipping. Concepts, Algorithms for line clipping. 1 of 16. Andries van Dam. Clipping - 10/12/17

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Clipping. Concepts, Algorithms for line clipping. 1 of 16. Andries van Dam. Clipping - 10/12/17 Clipping Concepts, Algorithms for line clipping 1 of 16 Line Clipping in 2D Clipping endpoints If x min x x max and y min y y max, the point is inside the clip rectangle. Endpoint analysis for lines: if

More information

CS 130 Exam I. Fall 2015

CS 130 Exam I. Fall 2015 S 3 Exam I Fall 25 Name Student ID Signature You may not ask any questions during the test. If you believe that there is something wrong with a question, write down what you think the question is trying

More information

Unit 2 Output Primitives and their Attributes

Unit 2 Output Primitives and their Attributes Unit 2 Output Primitives and their Attributes Shapes and colors of the objects can be described internally with pixel arrays or with sets of basic geometric structures, such as straight line segments and

More information

Output Primitives. Dr. S.M. Malaek. Assistant: M. Younesi

Output Primitives. Dr. S.M. Malaek. Assistant: M. Younesi Output Primitives Dr. S.M. Malaek Assistant: M. Younesi Output Primitives Output Primitives: Basic geometric structures (points, straight line segment, circles and other conic sections, quadric surfaces,

More information

Lab Manual. Computer Graphics. T.E. Computer. (Sem VI)

Lab Manual. Computer Graphics. T.E. Computer. (Sem VI) Lab Manual Computer Graphics T.E. Computer (Sem VI) Index Sr. No. Title of Programming Assignments Page No. 1. Line Drawing Algorithms 3 2. Circle Drawing Algorithms 6 3. Ellipse Drawing Algorithms 8 4.

More information

CS452/552; EE465/505. Clipping & Scan Conversion

CS452/552; EE465/505. Clipping & Scan Conversion CS452/552; EE465/505 Clipping & Scan Conversion 3-31 15 Outline! From Geometry to Pixels: Overview Clipping (continued) Scan conversion Read: Angel, Chapter 8, 8.1-8.9 Project#1 due: this week Lab4 due:

More information

Department of Computer Sciences Graphics Fall 2003 (Lecture 2) Pixels

Department of Computer Sciences Graphics Fall 2003 (Lecture 2) Pixels Pixels Pixel: Intensity or color sample. Raster Image: Rectangular grid of pixels. Rasterization: Conversion of a primitive s geometric representation into A set of pixels. An intensity or color for each

More information

UNIT -8 IMPLEMENTATION

UNIT -8 IMPLEMENTATION UNIT -8 IMPLEMENTATION 1. Discuss the Bresenham s rasterization algorithm. How is it advantageous when compared to other existing methods? Describe. (Jun2012) 10M Ans: Consider drawing a line on a raster

More information

2D Graphics Primitives II. Additional issues in scan converting lines. 1)Endpoint order. Want algorithms to draw the same pixels for each line

2D Graphics Primitives II. Additional issues in scan converting lines. 1)Endpoint order. Want algorithms to draw the same pixels for each line walters@buffalo.edu CSE 480/580 Lecture 8 Slide 1 2D Graphics Primitives II Additional issues in scan converting lines 1)Endpoint order Want algorithms to draw the same pixels for each line How handle?

More information

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1 graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1 graphics pipeline sequence of operations to generate an image using object-order processing primitives processed one-at-a-time

More information

From Vertices To Fragments-1

From Vertices To Fragments-1 From Vertices To Fragments-1 1 Objectives Clipping Line-segment clipping polygon clipping 2 Overview At end of the geometric pipeline, vertices have been assembled into primitives Must clip out primitives

More information

Clipping Points Consider a clip window which is rectangular in shape. P(x, y) is a point to be displayed.

Clipping Points Consider a clip window which is rectangular in shape. P(x, y) is a point to be displayed. Usually only a specified region of a picture needs to be displayed. This region is called the clip window. An algorithm which displays only those primitives (or part of the primitives) which lie inside

More information

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1 graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1 graphics pipeline sequence of operations to generate an image using object-order processing primitives processed one-at-a-time

More information

Topic 0. Introduction: What Is Computer Graphics? CSC 418/2504: Computer Graphics EF432. Today s Topics. What is Computer Graphics?

Topic 0. Introduction: What Is Computer Graphics? CSC 418/2504: Computer Graphics EF432. Today s Topics. What is Computer Graphics? EF432 Introduction to spagetti and meatballs CSC 418/2504: Computer Graphics Course web site (includes course information sheet): http://www.dgp.toronto.edu/~karan/courses/418/ Instructors: L0101, W 12-2pm

More information

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14

Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14 Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture - 14 Scan Converting Lines, Circles and Ellipses Hello everybody, welcome again

More information

CSCI 4620/8626. Coordinate Reference Frames

CSCI 4620/8626. Coordinate Reference Frames CSCI 4620/8626 Computer Graphics Graphics Output Primitives Last update: 2014-02-03 Coordinate Reference Frames To describe a picture, the world-coordinate reference frame (2D or 3D) must be selected.

More information

Raster Scan Displays. Framebuffer (Black and White)

Raster Scan Displays. Framebuffer (Black and White) Raster Scan Displays Beam of electrons deflected onto a phosphor coated screen Phosphors emit light when excited by the electrons Phosphor brightness decays -- need to refresh the display Phosphors make

More information

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Computer Graphics

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Computer Graphics r About the Tutorial To display a picture of any size on a computer screen is a difficult process. Computer graphics are used to simplify this process. Various algorithms and techniques are used to generate

More information

CS602 MCQ,s for midterm paper with reference solved by Shahid

CS602 MCQ,s for midterm paper with reference solved by Shahid #1 Rotating a point requires The coordinates for the point The rotation angles Both of above Page No 175 None of above #2 In Trimetric the direction of projection makes unequal angle with the three principal

More information

Write C++/Java program to draw line using DDA and Bresenham s algorithm. Inherit pixel class and Use function overloading.

Write C++/Java program to draw line using DDA and Bresenham s algorithm. Inherit pixel class and Use function overloading. Group A Assignment No A1. Write C++/Java program to draw line using DDA and Bresenham s algorithm. Inherit pixel class and Use function overloading. Aim: To draw line using DDA and Bresenham s algorithm

More information

Computer Graphics. Lecture 2. Doç. Dr. Mehmet Gokturk

Computer Graphics. Lecture 2. Doç. Dr. Mehmet Gokturk Computer Graphics Lecture 2 Doç. Dr. Mehmet Gokturk Mathematical Foundations l Hearn and Baker (A1 A4) appendix gives good review l Some of the mathematical tools l Trigonometry l Vector spaces l Points,

More information

Rendering. Basic Math Review. Rasterizing Lines and Polygons Hidden Surface Remove Multi-pass Rendering with Accumulation Buffers.

Rendering. Basic Math Review. Rasterizing Lines and Polygons Hidden Surface Remove Multi-pass Rendering with Accumulation Buffers. Rendering Rasterizing Lines and Polygons Hidden Surface Remove Multi-pass Rendering with Accumulation Buffers Basic Math Review Slope-Intercept Formula For Lines Given a third point on the line: P = (X,Y)

More information

An Improved Algorithm for Scan-converting a Line

An Improved Algorithm for Scan-converting a Line An Improved Algorithm for Scan-converting a Line *Md. Hasanul Kabir 1, Md. Imrul Hassan 2, Abdullah Azfar 1 1 Department of Computer Science & Information Technology (CIT) 2 Department of Electrical &

More information

R asterisation. Part I: Simple Lines. Affine transformation. Transform Render. Rasterisation Line Rasterisation 2/16

R asterisation. Part I: Simple Lines. Affine transformation. Transform Render. Rasterisation Line Rasterisation 2/16 ECM2410:GraphicsandAnimation R asterisation Part I: Simple Lines Rasterisation 1/16 Rendering a scene User space Device space Affine transformation Compose Transform Render Com pose from primitives (lines,

More information

Display Technologies: CRTs Raster Displays

Display Technologies: CRTs Raster Displays Rasterization Display Technologies: CRTs Raster Displays Raster: A rectangular array of points or dots Pixel: One dot or picture element of the raster Scanline: A row of pixels Rasterize: find the set

More information

Windowing And Clipping (14 Marks)

Windowing And Clipping (14 Marks) Window: 1. A world-coordinate area selected for display is called a window. 2. It consists of a visual area containing some of the graphical user interface of the program it belongs to and is framed by

More information

Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling

Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling Computer Graphics : Bresenham Line Drawing Algorithm, Circle Drawing & Polygon Filling Downloaded from :www.comp.dit.ie/bmacnamee/materials/graphics/006- Contents In today s lecture we ll have a loo at:

More information

3D Rendering Pipeline (for direct illumination)

3D Rendering Pipeline (for direct illumination) Clipping 3D Rendering Pipeline (for direct illumination) 3D Primitives 3D Modeling Coordinates Modeling Transformation Lighting 3D Camera Coordinates Projection Transformation Clipping 2D Screen Coordinates

More information