Computer graphics �subject code(22318)
BY A.I.MUSHRIF
Syllabus
Sr.no | Name of topics |
Unit 1 | Basics of computer graphics |
Unit 2 | Raster scan Graphics |
Unit 3 | Overview of Transformations |
Unit 4 | Windowing and clipping |
Unit 5 | Introduction to curves |
Weightage of marks
Sr.no | Topics | Marks |
1 | Basics of computer Graphics | 08 |
2 | Raster Scan Graphics | 18 |
3 | Overview of Transformations | 18 |
4 | Windowing and clipping | 14 |
5 | Introductions to Curves | 12 |
Total | 70 | |
Computer Graphics:�Overview of�Transformations
4
2D Transformations
5
x
y
x
y
x
y
2D Transformations
6
x
y
x
y
x
y
OpenGl transformations:
glTranslatef (tx, ty, tz);
glRotatef (theta, vx, vy, vz)
glScalef (sx,sy,sz)
……
2D Transformations
7
x
y
x
y
x
y
Applications:
Applications of 2D Transformations
2D Transformation
9
Point Representation
y
x’ = ax + by + c
OR
y’ = dx + ey + f
10
X’ a b c x
Y’ = d e f * y
1 0 0 1 1
Translation
11
The new point: (x’, y’)
x’ = x + tx
y’ = y + ty
(x,y)
(x’,y’)
OR P’ = P + T where P’ = x’ p = x T = tx
y’ y ty
tx
ty
3x3 2D Translation Matrix
12
x’ = x + tx
y’ y ty
Use 3 x 1 vector
x’ 1 0 tx x
y’ = 0 1 ty * y
1 0 0 1 1
Translation
13
Translate individual
vertices
2D Rotation
14
θ
θ
x
y
o
x
y
o
2D Rotation
15
(x,y)
(x’,y’)
θ
(x,y) -> Rotate about the origin by θ
(x’, y’)
How to compute (x’, y’) ?
φ
r
2D Rotation
16
(x,y)
(x’,y’)
θ
(x,y) -> Rotate about the origin by θ
(x’, y’)
How to compute (x’, y’) ?
φ
x = r cos (φ) y = r sin (φ)
r
x’ = r cos (φ + θ) y’ = r sin (φ + θ)
x
y
o
2D Rotation
17
(x,y)
(x’,y’)
θ
φ
r
x = r cos (φ) y = r sin (φ)
x’ = r cos (φ + θ) y = r sin (φ + θ)
x’ = r cos (φ + θ)
= r cos(φ) cos(θ) – r sin(φ) sin(θ)
= x cos(θ) – y sin(θ)
y’ = r sin (φ + θ)
= r sin(φ) cos(θ) + r cos(φ)sin(θ)
= y cos(θ) + x sin(θ)
2D Rotation
18
(x,y)
(x’,y’)
θ
φ
r
x’ = x cos(θ) – y sin(θ)
y’ = y cos(θ) + x sin(θ)
Matrix form?
x’ cos(θ) -sin(θ) x
y’ sin(θ) cos(θ) y
=
3 x 3?
3x3 2D Rotation Matrix
19
x’ cos(θ) -sin(θ) x
y’ sin(θ) cos(θ) y
=
(x,y)
(x’,y’)
θ
φ
r
x’ cos(θ) -sin(θ) 0 x
y’ sin(θ) cos(θ) 0 y
1 0 0 1 1
=
20
Rotate individual
Vertices
θ
2D Rotation
2D Scaling
21
Scale: Alter the size of an object by a scaling factor
(Sx, Sy), i.e.
x’ = x . Sx
y’ = y . Sy
x’ Sx 0 x
y’ 0 Sy y
=
(1,1)
(2,2)
Sx = 2, Sy = 2
(2,2)
(4,4)
2D Scaling
22
(1,1)
(2,2)
Sx = 2, Sy = 2
(2,2)
(4,4)
3x3 2D Scaling Matrix
23
x’ Sx 0 x
y’ 0 Sy y
=
x’ Sx 0 0 x
y’ = 0 Sy 0 * y
1 0 0 1 1
Put it all together
24
Or, 3x3 Matrix Representations
25
x’ 1 0 tx x
y’ = 0 1 ty * y
1 0 0 1 1
x’ cos(θ) -sin(θ) 0 x
y’ sin(θ) cos(θ) 0 * y
1 0 0 1 1
=
x’ Sx 0 0 x
y’ = 0 Sy 0 * y
1 0 0 1 1
Why use 3x3 matrices?
Why Use 3x3 Matrices?
(x,y,1) -> this is called Homogeneous
coordinates!
26
Why Use 3x3 Matrices?
(x,y,1) -> this is called Homogeneous
coordinates!
27
Shearing
28
x 1 h 0 x
y = 0 1 0 * y
1 0 0 1 1
29
x 1 0 0 x
y = g 1 0 * y
1 0 0 1 1
Shearing in Y
Reflection
30
Reflection
31
Reflection
32
Reflection about X-axis
33
Reflection about X-axis
34
x 1 0 0 x
y = 0 -1 0 * y
1 0 0 1 1
Reflection about Y-axis
35
Reflection about Y-axis
36
x -1 0 0 x
y = 0 1 0 * y
1 0 0 1 1
What’s the Transformation Matrix?
37
What’s the Transformation Matrix?
38
x -1 0 0 x
y = 0 -1 0 * y
1 0 0 1 1
39
cos(θ) -sin(θ) 0
sin(θ) cos(θ) 0
0 0 1
Rotation Revisit
Arbitrary Rotation Center
40
(px,py)
Arbitrary Rotation Center
41
(px,py)
Arbitrary Rotation Center
42
(px,py)
Arbitrary Rotation Center
43
(px,py)
44
x’ 1 0 px cos(θ) -sin(θ) 0 1 0 -px x
y’ = 0 1 py sin(θ) cos(θ) 0 0 1 -py y
1 0 0 1 0 0 1 0 0 1 1
Arbitrary Rotation Center
45
Arbitrary Rotation Center
46
47
48
Example of arbitrary rotation
49
Example of arbitrary rotation
50
Example of arbitrary rotation
51
Projections
PROJECTION METHODS
1. Parallel Projection
2.Perspective Projection
52
Types of projections
1.Parallel projection
2.Perspective projection
Parallel projection
A parallel projection is a projection of an object in three-dimensional space onto a fixed plane, known as the projection plane or image plane, where the rays, known as lines of sight or projection lines, are parallel to each other.
Projections
53
Parallel Projection
54
Parallel Projections
Types of parallel projection
55
Parallel Projections
Types of parallel projection
The projection of a single view of an object (such as a view of the front) onto a projection plane in which the lines of projection are perpendicular to the projection plane.
when the projection is perpendicular to the view plane. In short,
– direction of projection = normal to the projection plane.
– the projection is perpendicular to the view plane
56
Parallel Projections
Types of parallel projection
57
Orthographic Projections
58
Parallel Projections
Oblique projection
when the projection is not perpendicular to the view plane. In short,
.
59
Parallel Projections
Oblique projection
Cavalier: All lines perpendicular to the projection plane are projected with no change in length.
Cabinet: All lines perpendicular to the projection plane are projected to one half of their length. These give a realistic appearance of object.
.
60
Parallel Projections
Oblique projection
Cavalier: All lines perpendicular to the projection plane are projected with no change in length.
.
61
Parallel Projections
Oblique projection
Cabinet: All lines perpendicular to the projection plane are projected to one half of their length. These give a realistic appearance of object.
.
62
Parallel Projections
.
Fig orthographic projection
Fig Oblique projection
63
It is a type of drawing that graphically approximates on a planar (two-dimensional) surface (e.g. paper) the images of three-dimensional objects so as to approximate actual visual perception. It is sometimes also called perspective view or perspective drawing or simply perspective
Perspective projection
The object position are transformed to the view plane along lines that converge to a point called projection reference point or (center of projection)
Projections
64
Perspective Projections
65
Characteristics of perspective projection:
Perspective Projections
66
Perspective Projections
Types of perspective projection
67
Perspective Projections
Types of perspective projection
68
Perspective Projections
Fig : One point Perspective
69
Perspective Projections
70
Perspective Projections
Fig : Two point Perspective
71
Perspective Projections
72
Perspective Projections
Fig : Three point Perspective