1 lecture 4 graphical primitives rasterization: algorithmic approach rasterization: geometric...
Post on 20-Dec-2015
225 views
TRANSCRIPT
![Page 1: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/1.jpg)
1
Lecture 4
Graphical primitives
Rasterization: algorithmic approach
Rasterization: geometric approach
2D discrete lines, triangles
Discrete planes
3D discrete lines
Meshes of triangles
Graphical primitives in OpenGL
![Page 2: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/2.jpg)
2
Main elements of vector model
Lines Polylines,
polygons Curves Text
![Page 3: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/3.jpg)
3
Main elements of vector model
Lines Polylines,
polygons (simple, regular)
Curves Text
![Page 4: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/4.jpg)
4
Main elements of vector model
Lines Polylines,
polygons (simple, regular)
Curves Text
![Page 5: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/5.jpg)
5
Main elements of vector model
Lines Polylines,
polygons (simple, regular)
Curves Text
![Page 6: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/6.jpg)
6
Main elements of vector model
Lines Polylines, polygons (simple, regular) Curves
are represented by their coordinates
(x1,y1), (x2,y2), …, (xn,yn)
Coordinate system: origin, orientation of the axes, units
![Page 7: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/7.jpg)
7
Main elements of vector model
Attributes:
Color Thickness Line Style Fill Style Text Font/Style
![Page 8: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/8.jpg)
8
Main elements of vector model
Attributes:
Color Thickness Line Style Fill Style Text Font/Style
![Page 9: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/9.jpg)
9
Main elements of raster model
Pixels/voxels
pixel = picture element voxel = volume element
Represented as a bitmap
![Page 10: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/10.jpg)
10
Main elements of mixed model
Lines, curves, text are rasterized
![Page 11: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/11.jpg)
11
Main elements of mixed model
Lines, curves, text are rasterized
![Page 12: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/12.jpg)
12
Approaches to rasterization: Algorithmic Approach
Developing algorithms for the main geometrical primitives
Line segment Circle Curve Filled area
![Page 13: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/13.jpg)
13
Approaches: Algorithmic Approach. Deficiencies
It is difficult to determine whether a pixel belongs to an object
![Page 14: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/14.jpg)
14
Approaches: Algorithmic Approach. Deficiencies
It is difficult to determine the intersection of two objects
![Page 15: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/15.jpg)
15
Approaches: Algorithmic Approach. Deficiencies
In some cases the quality of the picture is not satisfactory
Algorithm
![Page 16: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/16.jpg)
16
Approaches: Algorithmic Approach. Deficiencies
In some cases the quality of the picture is not satisfactory
![Page 17: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/17.jpg)
17
Approaches: Algorithmic Approach. Deficiencies
In some cases the quality of the picture is not satisfactory
![Page 18: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/18.jpg)
18
Approaches: Geometric Approach.
Objectives of the Geometric Approach: Developing a relevant discrete counterpart of the
analytical geometry (Discrete Analytical Geometry). Developing efficient algorithms for generation of the
basic primitives of the discrete analytical geometry.
Advantages: Makes up the deficiencies of the algorithmic
approach. Exact arithmetic. Raising the computational efficiency of some
algorithms. Data compression.
![Page 19: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/19.jpg)
19
Approaches: Geometric Approach. Difficulties
The intersection of two discrete lines may be 0, 1, or infinitely many points.
![Page 20: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/20.jpg)
20
Approaches: Geometric Approach. Difficulties
The objects have thickness.
![Page 21: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/21.jpg)
21
Approaches: Geometric Approach. Difficulties
In 3D the things become much more complex.The intersection of two planes is not a line. It may be even a
disconnected set.
![Page 22: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/22.jpg)
22
Basic Definitions. Coordinate Systems, Pixels, Voxels
Def. 2D Coordinate system Only the integer points are included.
Pixels are unit squares centered about the integer points.
Voxels are unit cubes centered about the integer points.
![Page 23: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/23.jpg)
23
Basic Definitions. Discrete Adjacency
Def. 2D adjacency Let P1 and P2 be two pixels. They are
8-adjacent, if they share a vertex or an edge
4-adjacent, if they share an edge.
Remark: 4-adjacent pixels are also 8-adjacent.
![Page 24: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/24.jpg)
24
Basic Definitions. Discrete Adjacency
Def. 3D adjacency Let V1 and V2 be two voxels. They are 26-adjacent, if they share a vertex, an edge or a side. 18-adjacent, if they share an edge or a vertex. 6-adjacent, if they share a side.
Remark: The 6-adjacent voxels are also 18- and 26-adjacent and the 18-adjacent voxels are also 26-adjacent.
![Page 25: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/25.jpg)
25
Basic Definitions. 2D Lines
Def. 2D arithmetic line L(a,b, µ,w) is a set of pixels (x,y) satisfying the conditions
0 ax + by + µ < w
w - arithmetical thicknessµ - internal translation
constant
![Page 26: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/26.jpg)
26
Basic Definitions. 2D Lines
0 ax + by + µ < w0 3x - 5y < 5
x | y x | y------- --------0 | 0 8 | 4 1 | 0 9 | 52 | 1 10 | 63 | 1 11 | 64 | 2 12 | 75 | 3 13 | 7 6 | 3 14 | 87 | 4
![Page 27: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/27.jpg)
27
Basic Definitions. 2D Lines
0 3x - 5y < 5Let P = 3x - 5y
x | y | P x | y | P---------- ----------0 | 0 | 0 8 | 4 | 4
1 | 0 | 3 9 | 5 | 22 | 1 | 1 10 | 6 | 03 | 1 | 4 11 | 6 | 34 | 2 | 2 12 | 7 | 15 | 3 | 0 13 | 7 | 46 | 3 | 3 14 | 8 | 27 | 4 | 1
![Page 28: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/28.jpg)
28
Basic Definitions. Types of 2D Lines
If w<max(|a|, |b|): disconnected
If w=max(|a|, |b|): naïve
If w=|a|+|b|: standard
If w>|a|+|b|: thick
![Page 29: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/29.jpg)
29
Basic Definitions. Types of 2D Lines
If w<max(|a|, |b|): disconnected
If w=max(|a|, |b|): naïve
If w=|a|+|b|: standard
If w>|a|+|b|: thick
![Page 30: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/30.jpg)
30
Basic Definitions. Types of 2D Lines
If w<max(|a|, |b|): disconnected
If w=max(|a|, |b|): naïve
If w=|a|+|b|: standard
If w>|a|+|b|: thick
![Page 31: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/31.jpg)
31
Basic Definitions. Types of 2D Lines
If w<max(|a|, |b|): disconnected
If w=max(|a|, |b|): naïve
If w=|a|+|b|: standard
If w>|a|+|b|: thick
![Page 32: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/32.jpg)
32
Basic Definitions. Tunnels in 2D Lines
A line L (a,b,µ,w) has an k-tunnel, if there exist two k-adjacent pixels A and B, such that
axA+byA+µ<0 and
axB+byB+µw
![Page 33: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/33.jpg)
33
Basic Definitions. Bresenham Line
Bresenham line corresponding to the Euclidean line
ax + by + c = 0 is
0 ax + by + c+[w/2] < w,
where w=max(|a|, |b|)
![Page 34: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/34.jpg)
34
Discrete Triangles
Problems:
Def.: Let A, B, C be given.
Border: union of the Bresenham lines AB, BC, CA
Interior: All the integer points, belonging to the Euclidean triangle ABC, which do not belong to the border.
![Page 35: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/35.jpg)
35
Discrete Planes
Def. Discrete plane P(a,b,c,µ,w) is a set of voxels (x,y,z) satisfying the conditions
0 ax + by + cz + c < w
w - arithmetical thicknessµ - internal translation constant
Naïve plane: w=max(|a|, |b|, |c|}
Standard plane: w=|a|+|b|+|c|
![Page 36: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/36.jpg)
36
Discrete Planes
Def. Discrete plane P(a,b,c,µ,w) is a set of voxels (x,y,z) satisfying the conditions
0 ax + by + cz + c < w
w - arithmetical thicknessµ - internal translation constant
Naïve plane: w=max(|a|, |b|, |c|}
Standard plane: w=|a|+|b|+|c|
![Page 37: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/37.jpg)
37
Discrete Planes
Def. A plane P has a k-tunnel (n=6,18,26) if there exist two k-adjacent voxels A and B such that
axA + byA + czA + µ <0
and
axB + byB + czB + µ w
Tunnel-free is equivalent to 26-tunnel-free.
![Page 38: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/38.jpg)
38
Functionality
Def. A plane P is functional on a coordinate plane, e.g. Oxy, if for any voxel (x,y) from Oxy there is exactly one voxel belonging to P. The plane Oxy is called functional coordinate plane for P.
![Page 39: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/39.jpg)
39
3D Lines
Def. A 3D discrete line is defined as an intersection of two discrete planes.
0 - cx + az + µ < w
0 - cy + bz + µ’ < w’
![Page 40: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/40.jpg)
40
Graphical Primitives in OpenGL
OpenGL uses primitives to draw all the vector primitives that we studied: points, lines, polygons, rectangles, etc.
2D and 3D Remark: For 3D primitives we have to call projection
function, e.g. glOrtho as in the example of drawing triangle. All functions for drawing primitives start with
glBegin( PRIMITIVE_NAME ) and end with
glEnd().
![Page 41: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/41.jpg)
41
Graphical Primitives in OpenGL
Example: The following fragment draws one 3D point.
glBegin( GL_POINTS ); glVertex3f( 0.2, 0.4, 0.3 );glEnd();
Example: The following fragment draws four 3D point.
glBegin( GL_POINTS ); glVertex3f( 0.1, 0.1, 0 );
glVertex3f( 0.1, 0.5, 0 );glVertex3f( 0.5, 0.5, 0 );glVertex3f( 0.5, 0.1, 0 );
glEnd();
![Page 42: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/42.jpg)
42
Graphical Primitives in OpenGL
Example: The following fragment draws a square.
glColor3f( 1.0, 0.0, 0.0 );glBegin( GL_POLYGON ); glVertex3f( 0.1, 0.1, 0 );
glVertex3f( 0.1, 0.5, 0 );glVertex3f( 0.5, 0.5, 0 );glVertex3f( 0.5, 0.1, 0 );
glEnd();
![Page 43: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/43.jpg)
43
Graphical Primitives in OpenGL
Z-coordinate is zero. We can skip it.
glColor3f( 1.0, 0.0, 0.0 );glBegin( GL_POLYGON ); glVertex2f( 0.1, 0.1 );
glVertex2f( 0.1, 0.5 );glVertex2f( 0.5, 0.5 );glVertex2f( 0.5, 0.1 );
glEnd();
![Page 44: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/44.jpg)
44
Graphical Primitives in OpenGL
Remark: the order of the vertices is important. The program that we considered will draw the following
window:
My first OpenGL program
![Page 45: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/45.jpg)
45
Graphical Primitives in OpenGL
Remark: the order of the vertices is important. The program:
glColor3f( 1.0, 0.0, 0.0 );
glBegin( GL_POLYGON );
glVertex2f( 0.1, 0.5 );
glVertex2f( 0.1, 0.1 );
glVertex2f( 0.5, 0.5 );
glVertex2f( 0.5, 0.1 );
glEnd();My first OpenGL program
![Page 46: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/46.jpg)
46
List of the Primitives
![Page 47: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/47.jpg)
47
GL_POINTS
glColor3f( 0.0, 0.0, 1.0 );
glBegin(GL_POINTS);
glVertex3f( 0.1, 0.9, 0 );
glVertex3f( 0.1, 0.2, 0 );
glVertex3f( 0.9, 0.9, 0 );
glVertex3f( 0.9, 0.2, 0 );
glEnd();
![Page 48: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/48.jpg)
48
GL_POINTS
glColor3f( 0.0, 0.0, 1.0 );glBegin(GL_POINTS); glVertex3f( 0.1, 0.9, 0 );
glVertex3f( 0.1, 0.2, 0 ); glVertex3f( 0.9, 0.9, 0 );
glVertex3f( 0.9, 0.2, 0 );glEnd();
![Page 49: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/49.jpg)
49
GL_LINES: connects two points to form a line. Odd number of vertices: last ignored
glColor3f( 0.0, 0.0, 1.0 );glBegin(GL_LINES);
glVertex3f( 0.1, 0.2, 0 ); glVertex3f( 0.1, 0.9, 0 );
glVertex3f( 0.9, 0.9, 0 ); glVertex3f( 0.9, 0.2, 0 );glEnd();
![Page 50: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/50.jpg)
50
GL_LINE_STRIP: draws lines without lifting the pen
glColor3f( 0.0, 0.0, 1.0 );glBegin(GL_LINE_STRIP);
glVertex3f( 0.1, 0.2, 0 ); glVertex3f( 0.1, 0.9, 0 );
glVertex3f( 0.9, 0.9, 0 ); glVertex3f( 0.9, 0.2, 0 );glEnd();
![Page 51: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/51.jpg)
51
GL_LINE_LOOP do the same as GL_LINE_STRIP and connect the first and last points
glColor3f( 0.0, 0.0, 1.0 );glBegin(GL_LINE_LOOP);
glVertex3f( 0.1, 0.2, 0 ); glVertex3f( 0.1, 0.9, 0 );
glVertex3f( 0.9, 0.9, 0 ); glVertex3f( 0.9, 0.2, 0 );glEnd();
![Page 52: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/52.jpg)
52
GL_TRIANGLES take vertices in groups of three and draw triangles. If the number of Vertices is not divisible by 3, those vertices at the end are ignored.
What will this program fragment draw?
glColor3f( 0.0, 0.0, 1.0 );glBegin(GL_TRIANGLES);
glVertex3f( 0.1, 0.9, 0 );glVertex3f( 0.1, 0.2, 0 );
glVertex3f( 0.9, 0.9, 0 );glVertex3f( 0.9, 0.2, 0 );
glEnd();
![Page 53: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/53.jpg)
53
GL_TRIANGLE_STRIP also does this with the exception that every vertex after the first three forms a connected triangles( i.e., v0, v1, v2, then v2, v1 and v3, then v2, v3 and v4).
glColor3f( 0.0, 0.0, 1.0 );glBegin(GL_TRIANGLE_STRIP);
glVertex3f( 0.1, 0.2, 0.0 );glVertex3f( 0.1, 0.5, 0.0 );
glColor3f ( 1.0, 0.0, 0.0 );glVertex3f( 0.5, 0.5, 0.0 );glVertex3f( 0.5, 0.2, 0.0 );
glEnd();
![Page 54: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/54.jpg)
54
GL_TRIANGLE_FAN forms triangles that share the common first vertex.
glColor3f( 0.0, 0.0, 1.0 ); glBegin(GL_TRIANGLE_FAN);
glVertex3f( 0.1, 0.2, 0 );glVertex3f( 0.1, 0.9, 0 );
glVertex3f( 0.9, 0.5, 0 );glVertex3f( 0.5, 0.2, 0 );
glEnd();
![Page 55: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/55.jpg)
55
GL_QUADS takes vertices in-groups of four to draw four-side polygons. If the number of points is not divisible by 4, the last a few points are ignored.
glColor3f( 0.0, 0.0, 1.0 );glBegin(GL_QUADS);
glVertex3f( 0.1, 0.2, 0 );glVertex3f( 0.1, 0.5, 0 );glVertex3f( 0.5 ,0.5,0);glVertex3f( 0.5,0.2, 0 );glColor3f( 0.0, 1.0, 0.0 );
glVertex3f( 0.6,0.2, 0 ); glVertex3f( 0.6,0.6, 0 ); glVertex3f( 0.9,0.6, 0 ); glVertex3f( 0.9,0.2, 0 );glEnd();
![Page 56: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/56.jpg)
56
GL_QUADS takes vertices in-groups of four to draw four-side polygons. If the number of points is not divisible by 4, the last a few points are ignored.
GL_QUAD_STRIP draws quads(four sided polygons) using vertices v0, v1, v2, v3 then v4, v5, v6, v7.
![Page 57: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/57.jpg)
57
GL_POLYGON draws a polygon with the specified vertices
glColor3f( 0.0, 0.0, 1.0 );
glBegin(GL_POLYGON);
glVertex3f( 0.1, 0.2, 0 );
glVertex3f( 0.1, 0.9, 0 );
glVertex3f( 0.9, 0.9, 0 );
glVertex3f( 0.9, 0.2, 0 );
glEnd();
![Page 58: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/58.jpg)
58
![Page 59: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/59.jpg)
59
Approaches: Algorithmic Approach. Line Segment
![Page 60: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/60.jpg)
60
Approaches: Algorithmic Approach. Line Segment
![Page 61: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/61.jpg)
61
Approaches: Algorithmic Approach. Line Segment
Back
![Page 62: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/62.jpg)
62
Discrete Circles
Approaches:
y=sqrt(r2 – x2) – bad quality of the image
x=r.cos(φ), y=r.sin(φ) – slow
![Page 63: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/63.jpg)
63
Discrete Circles
Symmetry: The formula y=sqrt(r2 – x2) is used for the second
octant. The symmetry of the circle is explored
![Page 64: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/64.jpg)
64
Discrete Circles
![Page 65: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/65.jpg)
65
Discrete Circles
Back
![Page 66: 1 Lecture 4 Graphical primitives Rasterization: algorithmic approach Rasterization: geometric approach 2D discrete lines, triangles Discrete planes 3D](https://reader036.vdocument.in/reader036/viewer/2022062421/56649d4b5503460f94a29033/html5/thumbnails/66.jpg)
66
Approaches: Algorithmic Approach. Deficiencies
for i:= 1 to 200 do
Circle (x, y, i);
Back