Unit 2 - Part 1
Unit 2 - Part 1
Augmented and
Virtual Reality
UNIT - II
UNIT II :
Visual Computation in Virtual Reality: Fundamentals of Computer
Graphics - Software and Hardware Technology on Stereoscopic Display
- Advanced Techniques in CG: Management of Large Scale
Environments & Real Time Rendering.
Visual Computation in Virtual Reality
• Components of CG
Fundamentals of • Modeling, Storing, Manipulation, Viewing and Rendering
• Graphic system
Computer Graphics
Raster and Random display
Based on television technology.
• The electron beam is swept across the screen,
one row at a time, from top to bottom.
• Each row is called a scan line.
• Picture definition is stored in a memory called
refresh buffer or frame buffer.
• Each screen spot is referred as a pixel or pel.
• Refreshed at 24 frames per second (fps) or
higher to remove flickering
Modeling – Output primitives
• The basic objects out of which a graphics
display is created
• Describes the geometry of objects and –
typically referred to as geometric
primitives.
• Examples: point, line, text, filled region,
images, quadric surfaces, spline curves
• Each of the output primitives has its own
set of attributes.
Two Dimensional Images
• Use Cartesian coordinates +Y
• X (horizontal)
• Y (vertical)
• The image seen on a screen Y
space is called the world
coordinate system Axis
(0,0) X Axis +X
Partition the space into pixels
Screen Coordinates – references to frame buffer locations
1. Define a set of points +Y
(vertices) in 2D space.
2. Given a set of vertices, (2,7) (9,7)
draw lines between
consecutive vertices.
(2,1) (9,1)
+X
Absolute and Relative Coordinate Specifications
+Y
• Absolute coordinates –
location specified as a
(0,6) (7,0)
relationship to the origin
• Relative coordinates –
location specified as a
relationship to other points
(2,1) (0,-6)
4, 8 – Connectors - Filling
Manipulation
• Translation
• Rotation
• Scaling
• Reflection
• Shearing
2D Transformations
Basic 2D Transformations (rigid-body
transformations):
Translation
Rotation
Scaling
Homogenenous Representations and
Coordinates
2D Composite Transformations
Other Transformations:
Reflection
Shearing
Geometric Transformations 15
2D Translation
P’
T
x’ = x + tx , y’ = y + ty P
x x' t x
P = , P ' = , T =
y y ' t y
P’=P+T
Translation moves the object without deformation (rigid-body
transformation)
16
2. Rotation
2D Rotation
Rotation axis
Rotation angle
rotation point or pivot point (xr,yr)
Note:
If θ is positive → counterclockwise
If θ is negative → clockwise
rotation
yr θ Remember:
cos(a + b) = cos a cos b - sin a sin b
cos(a - b) = cos a sin b + sin a cos b
xr
17
Rotation
(x’,y’)
r θ
r (x,y)
Φ
18
2D Rotation
P’=R·P
cos − sin
R=
sin cos
(x’,y’)
r θ
r (x,y)
Φ
19
2D Rotation
Rotation of a point about any specified position (xr,yr)
x’=xr+(x - xr) cos θ – (y - yr) sin θ
y’=yr+(x - xr) sin θ + (y - yr) cos θ
Rotations also move objects without deformation
A line is rotated by applying the rotation formula to each of
the endpoints and redrawing the line between the new end
points
A polygon is rotated by applying the rotation formula to each
of the vertices and redrawing the polygon using new vertex
coordinates
20
3. Scaling
or P’ = S·P
x' s x 0 x
y ' = 0
sy y
21
Any positive value can be used as scaling factor
Values less than 1 reduce the size of the object
Values greater than 1 enlarge the object
If scaling factor is 1 then the object stays unchanged
If sx = sy , we call it uniform scaling
If scaling factor <1, then the object moves closer to the origin and
If scaling factor >1, then the object moves farther from the origin
x’ x 22
We can control the location of the scaled object by choosing
a position called the fixed point (xf,yf)
x’ – xf = (x – xf) sx y’ – yf = (y – yf) sy
x’=x · sx + xf (1 – sx)
y’=y · sy + yf (1 – sy)
Polygons are scaled by applying the above formula to each
vertex, then regenerating the polygon using the transformed
vertices
23
Matrix Representations and 24
Homogeneous Coordinates
Many graphics applications involve sequences of geometric
transformations
Animations
Design and picture construction applications
We will now consider matrix representations of these operations
Sequences of transformations can be efficiently processed using
matrices
25
P’ = M1 · P + M2
P and P’ are column vectors
M1 is a 2 by 2 array containing multiplicative factors
M2 is a 2 element column matrix containing translational terms
For translation M1 is the identity matrix
For rotation or scaling, M2 contains the translational terms associated
with the pivot point or scaling fixed point
26
x' 1 0 t x x
y ' = 0 1 t y
y
1 0 0 1 1
or, P’ = T(tx,ty)·P
29
2D Rotation Matrix
or, P’ = R(θ)·P
30
2D Scaling Matrix
x' s x 0 0 x
y ' = 0 sy 0 y
1 0 0 1 1
or, P’ = S(sx,sy)·P
31
Inverse Transformations
1 0 − t x
T −1 = 0 1 − t y
0 0 1
By the way:
−1
T *T = I
32
2D Inverse Rotation Matrix
cos sin 0
−1
R = − sin cos 0
0 0 1
And also:
−1
R *R = I
33
2D Inverse Rotation Matrix:
If θ is negative → clockwise
In
−1
R * R = I
Only sine function is affected
Therefore we can say
−1
R =R T
34
2D Inverse Scaling Matrix
1
s 0 0
x
1
S −1 = 0 0
sy
0 0 1
Of course:
−1
S *S = I
35
We can setup a sequence of transformations as a
composite transformation matrix by calculating the product
of the individual transformations
P’=M2·M1·P
=M·P
36
Composite 2D Translations
If two successive translation are applied to a point P, then the final
transformed location P' is calculated as
1 0 t 2 x 1 0 t1x 1 0 t1x + t 2 x
0 1 t 0 1 t = 0 1 t + t
2y 1y 1y 2y
P ' = R (1 + 2 ) P
38
Composite 2D Scaling
s2 x 0 0 s1x 0 0 s1x s2 x 0 0
0 s2 y 0 0 s1 y 0 = 0 s1 y s2 y 0
0 0 1 0 0 1 0 0 1
39
40
Note:
Successive translations are additive
Successive scalings are multiplicative
For example: If we triple the size of an object twice, the final size
is nine (9) times the original
Rotation w.r.t to pivot point
41
Steps:
1. Translate the object so that the pivot point is moved to the
coordinate origin.
2. Rotate the object about the origin.
3. Translate the object so that the pivot point is returned to its
original position.
General 2D Pivot-Point Rotation
1 0 xr cos − sin 0 1 0 − xr
0 1 yr sin cos 0 0 1 − yr
0 0 1 0 0 1 0 0 1
42
General Fixed Point Scaling 43
Steps:
1. Translate the object so that the fixed point coincides with
the coordinate origin.
2. Scale the object about the origin.
3. Translate the object so that the pivot point is returned to its
original position.
1 0 𝑥𝑓 𝑠𝑥 0 0 1 0 − 𝑥𝑓 𝑠𝑥 0 𝑥𝑓 (1 − 𝑠𝑥 )
0 1 𝑦𝑓 . 0 𝑠𝑦 0 . 0 1 − 𝑦𝑓 = 0 𝑠𝑦 𝑦𝑓 (1 − 𝑠𝑦 )
001 0 0 1 00 1 0 0 1
(cont.)
◼ General procedure:
1. Rotate so that directions coincides with x and y
axes
2. Apply scaling transformation 𝑆 𝑠1 , 𝑠2
3. Rotate back
◼ The composite matrix:
𝑠1 cos 2 Θ + 𝑠2 sin2 Θ 𝑠2 − 𝑠1 cos Θ sin Θ 0
𝑅−1 Θ ∗ 𝑆 𝑠1 , 𝑠2 ∗ 𝑅 Θ = 𝑠2 − 𝑠1 cos Θ sin Θ 𝑠1 sin2 Θ + 𝑠2 cos 2 Θ 0
0 0 1
2D Composite Transformations 48
(cont.)
Matrix Concatenation Properties:
Matrix multiplication is associative !
M3· M2· M1= (M3· M2 ) · M1 = M3· ( M2 · M1 )
A composite matrix can be created by multiplicating left-to-right
(premultiplication) or right-to-left (postmultiplication)
Matrix multiplication is not commutative !
M2 · M1 ≠ M1 · M2
2D Composite Transformations 49
(cont.)
Matrix Concatenation Properties:
But:
Two successive rotations
Two successive translations
Two successive scalings
are commutative
Reversing the order 50
1 0 0
0 − 1 0
0 0 1
ii. Reflection about y- axis 53
− 1 0 0
0 1 0
0 0 1
iii. Reflection about origin 54
−1 0 0
0 −1 0
0 0 1
iv. Reflection about y = x 55
0 1 0
1 0 0
0 0 1
v. Reflection about y = x 56
0 −1 0
−1 0 0
0 0 1
57
vi. Reflection about line y =mx + c
Steps
1. Translate the line so that it passes
through the origin.
2. Rotate the line onto one of the
coordinate axes and reflect about that
axis
3. Restore the line to its original position
with the inverse rotation and translation
transformation
5. Shear 58
y y
(2,1) (3,1)
(0,1) (1,1)
1 shx 0
0 1
0 x' = x + shx y
0 0 1 y' = y
An y-direction shear relative to the y axis
1 0 0
sh
1 0
y
0 0 1
X axis - Shear 60
1 0 0
sh
1 − shy * xref
y
0 0 1
x' = x
y ' = x + shy * (x − xref )
Example 63
y0 θ
0 x0 x
Transformation Between 67
Coordinate Systems (cont.)
y0
θ
0 x0 x
Transformation Between 68
Coordinate Systems (cont.)
y0
y′
0 x′ x0 x
Transformation Between 69
Coordinate Systems (cont.)
1 0 − 𝑥0
𝐓(−𝑥0 , −𝑦0 ) = 0 1 − 𝑦0
0 0 1
𝐶𝑜𝑠𝜃 𝑆𝑖𝑛𝜃 0
𝐑(−𝜃) = −𝑆𝑖𝑛𝜃 𝐶𝑜𝑠𝜃 0
0 0 1
𝐌𝑥𝑦,𝑥′𝑦′ = 𝐑(−𝜃) ⋅ 𝐓(−𝑥0 , −𝑦0 )
Transformation Between 70
Coordinate Systems (cont.)
An alternative method:
-Specify a vector V that indicates the direction
for the positive y′ axis. Let
𝐕
𝐯= = (𝑣𝑥 , 𝑣𝑦 )
𝐕 -Obtain the unit vector u=(ux ,u y) along the x′ axis by rotating v 900
clockwise.
Transformation Between 71
Coordinate Systems (cont.)
Elements of any rotation matrix can be expressed as elements of
orthogonal unit vectors. That is, the rotation matrix can be
written as
𝑢𝑥 𝑢𝑦 0
𝐑 = 𝑣𝑥 𝑣𝑦 0
0 0 1
Transformation Between 72
Coordinate Systems (cont.)
y0
0 x0 x
2D viewing pipeline
References
• Images and videos used in this presentation are referred from the
Internet source
• D. Hearn and M. P. Baker, “Computer Graphics - C version”, Pearson
Education, 2004.