0% found this document useful (0 votes)
45 views29 pages

Computer Graphics and Visualization: Module-2

This document discusses 2D graphics topics including polygon fill areas, geometric transformations, and 2D viewing. It describes how to classify polygons as convex or concave and techniques for splitting concave polygons. It also covers the OpenGL functions for drawing filled polygons and the general scanline algorithm for polygon filling. Finally, it examines 2D geometric transformations including translation, rotation, scaling and their representation using transformation matrices.

Uploaded by

PlayIt All
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views29 pages

Computer Graphics and Visualization: Module-2

This document discusses 2D graphics topics including polygon fill areas, geometric transformations, and 2D viewing. It describes how to classify polygons as convex or concave and techniques for splitting concave polygons. It also covers the OpenGL functions for drawing filled polygons and the general scanline algorithm for polygon filling. Finally, it examines 2D geometric transformations including translation, rotation, scaling and their representation using transformation matrices.

Uploaded by

PlayIt All
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

COMPUTER GRAPHICS AND VISUALIZATION

Module-2
Fill area Primitives, 2D Geometric Transformations and 2D viewing

C.K.SRINIVAS
Associate Professor
Dept. of CS&E
BITM, Ballari.
Cell: 9886684832
Email: srinivasck9@gmail.com
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

5 POLYGON FILL AREAS

polygon

Polygon Classifications
interior angle
convex.

concave

FIGURE 2-1

Identifying Concave Polygons

2
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

FIGURE 2-2

Splitting Concave Polygons

vector
method
V V
E V V

FIGURE 2-3

E E
E E
E E

3
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

E E

E E E E
E E E E
E E E E

E E
E

Inside-Outside Tests

odd-even rule,
P

P P

nonzero winding-number rule,

winding number.

P
P

P P
P

4
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

FIGURE 2-4

Polygon Tables

FIGURE 3-5

5
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

Plane Equations

6
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

Front and Back Polygon Faces


backface,
front face.

FIGURE 3-52 FIGURE 3-53 N


x •• •••• Ax • • •By
• • • •Cz
• • • •D• • • • •
A B C

7
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

normal vector

OpenGL POLYGON FILL-AREA FUNCTIONS

GL_POLYGON

glBegin
glVertex GL POLYGON

FIGURE 3-56 (a)

8
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

GL_TRIANGLES

FIGURE 3-56 GL TRIANGLES

GL_TRIANGLE_STRIP

FIGURE 3-56 GL TRIANGLE STRIP

9
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

GL_TRIANGLE_FAN

glBegin (GL_TRIANGLE_FAN);
glVertex2iv (p1);
glVertex2iv (p2);
glVertex2iv (p3);
glVertex2iv (p4);
glVertex2iv (p5);
glVertex2iv (p6);
glEnd ( );

FIGURE 3-56 GL TRIANGLE FAN

GL_QUADS

glBegin (GL_QUADS);
glVertex2iv (p1);
glVertex2iv (p2);
glVertex2iv (p3);
glVertex2iv (p4);
glVertex2iv (p5);
glVertex2iv (p6);
glVertex2iv (p7);
glVertex2iv (p8);
glEnd ( );

FIGURE 3-57
GL QUADS

GL_QUAD_STRIP

glBegin (GL_QUAD_STRIP);
glVertex2iv (p1);
glVertex2iv (p2);
glVertex2iv (p4);
glVertex2iv (p3);
glVertex2iv (p5);
glVertex2iv (p6);
glVertex2iv (p8);
glVertex2iv (p7);
glEnd ( );
FIGURE 3-57 GL QUAD STRIP

10
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

Filled area primitives

General Scan-Line Polygon-Fill Algorithm

F I G U R E 3.58
Interior pixels along a scan line passing through a polygon fill area.

11
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

F I G U R E 3-59

12
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

13
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

14
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

15
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

F I G U R E 3-61 A polygon and its sorted edge table, with edge DC shortened by one unit in the y direction

Two Dimensional Geometric Transformations

16
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

Translation, Rotation, and Scaling

Translation

= +

Scaling

17
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing





= *

Rotation:

Figure: Rotation about a fixed point

18
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

= *

Matrix Representation and homogeneous Coordinates

19
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

For Translation For Scaling For Rotations

Composite Transformations

composite transformation matrix

Translation

Rotations

20
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

Scaling

OR

S S S

General Pivot-point Rotation

FIGURE: R

21
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

T xr yr • •R • T • • •xr • •yr • • •R• xr yr


T • •xr • •yr • • T
• •• • xr yr

General Two-Dimensional Fixed-Point Scaling

1.
2.
3.

or

T x f yf • • •S• sx sy • T
• • •x f • •yf • • S
• • x f yf sx sy

22
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

Other Transformations

Reflection

Reflection of an object about the x axis

F I G U R E:

Reflection of an object about the y axis

23
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

Reflection of an object about the coordinate origin

Reflection axis as the diagonal line y = x

Reflection about the diagonal line y=x is


accomplished with the transformation matrix

24
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

Shearing





= *

25
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

Two dimensional viewing

The viewing pipeline

A viewing transformation using standard rectangles for the window and viewport

The two dimensional viewing transformation pipeline

26
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

OpenGL Two-Dimensional Viewing Functions

glMatrixMode (GL_PROJECTION);

glLoadIdentity ( );

GLU Clipping-Window Function

gluOrtho2D (xwmin, xwmax, ywmin, ywmax);

gluOrtho2D

27
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

OpenGL Viewport Function

glViewport (xvmin, yvmin, vpWidth, vpHeight);

xvmin yvmin

28
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.
Module – 2: Fill area Primitives, 2D Geometric Transformations and 2D viewing

Questions
Sl.No Module – 2: Marks

Fill area Primitives, 2D Geometric Transformations and 2D viewing


1 Explain Scanline Polygon Filling Algorithm with neat sketches and example. 08

2 With a neat figure explain two dimensional viewing pipeline. 08

3 Discuss various polygon types in OpenGL. 08

4 Define Polygon Tables. Explain How Geometric data is represented for the objects in a 10
scene. Give example.

5 Explain the following 10


a) OpenGL fill area attributes functions b) OpenGL viewing Functions
c) OpenGL geometric transformations functions

6 What is transformation; explain what you understand by Affine transformation. ( June/July 10


2009)

7 Define the following two dimensional transformations Translation, Rotation, Scaling, and 10
Reflection (Dec 09/Jan 10)

8 Explain the following in homogeneous Rotation, translation, scaling, and shearing 12

(June/July 2009) June 2010

9 Explain the current transformation matrix (CTM) in OpenGL ( Dec 09/Jan 10) Or Explain 08
how rotation, translation & scaling is considered in OpenGL Current Transformation Matrix
(CTM)

10 What is concatenation of transformation? Explain the following considered 2D 10

i. Rotation About a fixed point ( June/July 2011)


ii. Scaling About a fixed point.
iii. Two Translations are additive in nature.
iv. Two Rotations are additive in nature
v. Two Scaling are multiplicative in nature

29
C.K.SRINIVASA, Asso. Prof. Dept Of CS&E, BITM, BALLARI.

You might also like