SlideShare a Scribd company logo
1 of 47
Download to read offline
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
By Avinash Juriani
M.Tech IIT ISM DHN
B.Tech SRM Chennai
M.Tech Notes Advanced Robotics
9/30/14 1/46
Transformations
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
Geometric Transformations
2D and 3D
9/30/14 2/45
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
 Objects in a scene at the lowest level are a collection of vertices…
 These objects have location, orientation, size
 Correspond to transformations: Translation (T), Rotation (R), and Scaling (S)
9/30/14 3/45
How do we use Geometric Transformations? (1/2)
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
 A scene has a camera/view point from which the scene is viewed
 The camera has some location and some orientation in 3-space …
 These correspond to Translation and Rotation transformations
 Need other types of viewing transformations as well - learn about them shortly
9/30/14 4/45
How do we use Geometric Transformations? (2/2)
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 5/45
Some Linear Algebra Concepts...
 3D coordinate geometry
 Vectors in 2 space and 3 space
 Dot product and cross product – definitions and uses
 Vector and matrix notation and algebra
 Identity matrix
 Multiplicative associativity
 E.g. A(BC) = (AB)C
 Matrix transpose and inverse – definition, use, and calculation
 Homogeneous coordinates (x, y, z, w)
You will need to understand these concepts!
Linear algebra help session notes:
http://cs.brown.edu/courses/cs123/resources/Linear_Algebra.pdf
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 6/45
Linear Transformations (1/3)
 We represent vectors as bold-italic letters
(v) and scalars as italic letters (c)
 Any vector in the plane can be defined as the
sum of two non-collinear basis vectors
 Recall that a basis for a vector space is a set
of vectors with the following properties:
1. The vectors in the set are linearly
independent
2. Any vector in the vector space can be
expressed as a linear combination of the
basis vectors
 Multiplying a vector by a scalar changes the
vector’s magnitude
v = a + bv
b
a
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 7/45
Linear Transformations (2/3)
 Definition of a linear function f:
 f(v+w) = f(v) + f(w) for all v and w in the domain of f
 f(cv) = cf(v) for all scalars c and elements v in the domain
 Example: f(x) = f(x1 , x2) := (3x1+2x2 , -3x1+4x2)
 Now let v and w be two elements in the domain of f
 f(v+w) = f(v1+w1 , v2+w2)
= (3(v1+w1)+2(v2+w2) , -3(v1+w1)+4(v2+w2))
= (3v1+2v2 , -3v1+4v2) + (3w1+2w2 , -3w1+4w2)
= f(v) + f(w)
 We can check the second property the same way
 Both properties must be satisfied for the function f to be linear
e1
e2
f(e1)
f(e2)
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
 Graphical use: transformations of points
around the origin (leaves the origin
invariant)
 These include Scaling and Rotations
 Translation is not a linear function (moves
the origin)
 Any linear transformation of a point will
result in another point in the same
coordinate system, transformed about the
origin
 Aside: How do we know the origin is
invariant from the definition of linearity?
9/30/14 8/45
Linear Transformations (3/3)
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 9/45
Linear Transformations as Matrices (1/2)
 Linear transformations can be represented as invertible (non-singular)
matrices
 Let’s start with 2D transformations. These can be represented by 2x2
matrices:
 A transformation of an arbitrary column vector x = has the form:
T =
a b
c d
é
ë
ê
ù
û
ú






2
1
x
x


























21
21
2
1
2
1
dxcx
bxax
x
x
dc
ba
x
x
T
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 10/45
Linear Transformations as Matrices (2/2)
 Let e1 and e2 be the standard basis vectors:
 Now substitute each basis vector for x to get:
 Notice that the columns of the matrix representation of our transformation matrix T are
precisely T applied to e1 and e2:
 This gives us a strategy for deriving transformation matrices!
 We can derive the columns of a transformation matrix one by one by considering how our
desired transformation affects each of the standard unit vectors.
























c
a
dc
ba
T
0
1
0
1
























d
b
dc
ba
T
1
0
1
0
e1 = 1
0
é
ë
ê
ù
û
ú, e2 = 0
1
é
ë
ê
ù
û
ú
T(e1) =
a
c
é
ë
ê
ù
û
ú, T(e2 ) =
b
d
é
ë
ê
ù
û
ú
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
•
9/30/14 11/45
Scaling in 2D (1/2)
Side effect: House shifts
position relative to origin
 Scale x by 3, y by 2 (Sx = 3, Sy = 2)
 v = (original vertex); v’ = (new vertex)
 v’ = Sv
 Derive S by determining how e1 and e2 should be
transformed
 (scale in X by Sx)
 (scale in Y by Sy)
 Thus we obtain






y
x






'
'
y
x







y
x
s
s
S
0
0






1
3






2
6






2
9
•
2
1
é
ë
ê
ù
û
ú
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 12/45
Scaling in 2D (2/2)
 S is a diagonal matrix; we can quickly
check using matrix multiplication that
our derivation is correct:
 S multiplies each coordinate of v by
the appropriate scaling factor, as
expected
 In general, the ith entry of Dv, where D
is diagonal, is (D[i,i] * v[i])

























'
'
0
0
y
x
ys
xs
y
x
s
s
y
x
y
x
Sv
 Properties of scaling to look out for:
 Does not preserve angles between lines
in the plane (except when scaling is
uniform, i.e. sx = sy)
 If the object doesn’t start at the origin,
scaling will move it closer to or farther
from the origin (often not desired)
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 13/45
Rotation in 2D (1/2)
 Rotate by θ about the origin
 v’ = Sv, where
 v = (original vertex)
 v’ = (new vertex)
 Derive Rθ by determining how e1 and e2
should be transformed:
 (first column of Rθ)
 (second column of Rθ)






y
x







'
'
y
x
Þ Rq =
cosq -sinq
sinq cosq
é
ë
ê
ù
û
ú
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 14/45
Rotation in 2D (2/2)
 Let’s try matrix-vector multiplication
 Rθ * v =


 Other properties of rotation:
 Preserves lengths in objects and angles between parts of objects (rigid-body rotation)
 For objects not centered at the origin, an unwanted translation might be introduced
(rotation is always about the origin)
v'
























 
'
'
cossin
sincos
cossin
sincos
y
x
yx
yx
y
x




x'= xcosq - ysinq
y'= xsinq + ycosq
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 15/45
What about translation?
 If we could treat all transformations
in a consistent manner, i.e., with
matrix representation, then could
combine transformations by
composing their matrices
 Let’s try using a matrix again
 How? Homogeneous Coordinates:
add an additional dimension, the w-
axis, and an extra coordinate, the w-
component
 Thus 2D -> 3D (effectively the
hyperspace for embedding 2D space)
 Translation is not a linear
transformation (the origin is not
invariant)
 Therefore, it can’t be represented as a
2x2 invertible matrix
 Question: Is there another solution?
 Answer: Yes, v’ = v + t, where t =
 However, using vector addition is not
consistent with our method of treating
transformations as matrices






dy
dx
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 16/45
Homogeneous Coordinates (1/3)
 Allow expression of all three 2D
transformations as 3x3 matrices
 We start with the point P2d on the xy plane
and apply a mapping to bring it to the w-
plane in the hyperspace
 P2d(x,y)  Ph(wx, wy, w), w≠0
 The resulting (x’,y’) coordinates in our new
point Ph are different from the original
(x,y), since x’ = wx, y’ = wy
 Ph(x’, y’, w), w ≠ 0
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 17/45
Homogeneous Coordinates (2/3)
 Once we have this point, we can apply a
homogenized version of our T, R and S
transformation matrices (next slides) to
get a new point in the hyperspace
 Finally, we want to obtain the
corresponding point in 2D-space, so
perform the inverse of the previous
mapping (divide all entries by w)
 The vertex v = is now represented as
v =






y
x










1
y
x
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 18/45
Homogeneous Coordinates (3/3)
 The transformations we use will always map points in the hyperplane defined
by w = 1 to other such points. (That way, we don’t have to divide by w to get
our equivalent point in 2D)
 In other words, we want our transformations T to map points v = to
points v’ =
 How do we achieve this with the matrices we have already derived?
 For linear transformations (i.e. scaling and rotation), embed the existing
matrix in the upper-left of a new 3x3 matrix:










1
y
x










1
'
'
y
x










100
0
0
dc
ba
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 19/45
Back to Translation
 Our translation matrix (T) can now be represented by embedding the
translation vector in the right column:
 To verify that this is the right matrix, multiply it by our homogenized point:
 Coordinates have been translated, and v’ is still homogeneous











100
10
01
dy
dx
T
v'Tv 


































11100
10
01
dyy
dxx
y
x
dy
dx
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
 Let’s homogenize our all matrices! Doesn’t affect linearity of scaling and rotation
 Our new transformation matrices look like this…
 Note: These transformations are called affine transformations, which means they
preserve ratios of distances between points on a straight line
9/30/14 20/45
Transformations Homogenized
Transformation Matrix
Scaling
Rotation
Translation
sx 0 0
0 sy 0
0 0 1
é
ë
ê
ê
ê
ê
ù
û
ú
ú
ú
ú
cosq -sinq 0
sinq cosq 0
0 0 1
é
ë
ê
ê
ê
ù
û
ú
ú
ú
1 0 dx
0 1 dy
0 0 1
é
ë
ê
ê
ê
ù
û
ú
ú
ú
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 21/45
Examples
 Scaling: Scale by 15 in the x direction, 17 in the y
 Rotation: Rotate by 123o
 Translation: Translate by -16 in the x direction, +18 in the y









 
100
0)123cos()123sin(
0)123sin()123cos(










100
0170
0015












100
1810
1601
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
 Up until now, we’ve only used the notion of a point in our 2D space
 We now present a distinction between points and vectors
 We used homogeneous coordinates to more conveniently represent translation;
hence points are represented as (x, y, 1)T
 A vector can be rotated/scaled, but not translated (can think of it as always starting
at origin), so don’t use the homogeneous coordinate: (x, y, 0)T
 That way, the translation matrix won’t have any affect on our vectors.
 For now, let’s focus on just our points (typically vertices)
9/30/14 22/45
Before we continue! Vectors vs. Points
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
 When we want to undo a transformation, we’ll need to find the matrix’s inverse.
 Thanks to homogenization, they are all invertible!
9/30/14 23/45
Inverses
Transformation Matrix Inverse Does it make sense?
Scaling If you scale something by factor a, the
inverse is scaling by 1/a
Rotation Inverse of rotation by θ is rotation by
–θ. The properties sin(-θ) = -sin(θ) and
cos(-θ) = cos(θ) give this matrix. Also,
the matrix is orthonormal, so inverse is
just the transpose (see next slide).
Translation If you translate by x, the inverse is
translation by -x
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 24/45
A moment of appreciation for linear algebra
 The inverse of a rotation matrix M is just its transpose MT! That’s really
convenient, so let’s understand how it works using orthonormal matrices
 Take a rotation matrix M = [v1 v2 v3] (where each vi is a vector)
 First note some properties of M
 The columns are orthogonal to each other: vi • vj = 0 (i ≠ j)
 Columns have unit length: ||vi|| = 1
 Let’s see what multiplying MT and M produces:
 Using the properties above, we see that this is the identity matrix, so MT = M-1


































332313
322212
312111
321
321
321
333
222
111
vvvvvv
vvvvvv
vvvvvv
vvv
vvv
vvv
vvv
vvv
vvv
zzz
yyy
xxx
zyx
zyx
zyx
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 25/45
More with Homogeneous Coordinates
Some uses we’ll see later:
 Placing sub-objects in parent’s coordinate system to construct hierarchical
scene graph
 Transforming primitives in their own coordinate systems
 View volume normalization
 Mapping arbitrary view volume into canonical view volume along z-axis
 Parallel (orthographic, oblique) and perspective projections
 Perspective transformation (turn viewing pyramid into a cuboid to turn
perspective projection into parallel projection) after perspective foreshortening
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 26/45
Composition of Transformations (2D) (1/2)
 We now have a number of tools at our disposal; we can combine them!
 An object in a scene uses many transformations in sequence. How do we
represent this in terms of functions?
 Transformation is a function; by associativity, we can compose functions:
 (f o g)( i )
 This is the same as first applying g, then applying f:
 f( g( i ) )
 Consider our functions f and g as matrices (M1 and M2) and our input as a
vector v
 Our composition is equivalent to M1M2v
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 27/45
Composition of Transformations (2D) (2/2)
 We can now form compositions of transformation matrices to form a more complex
transformation
 For example, TRSv, which scales a point, then rotates it, then translates it:
 Note that we apply the matrices in sequence right to left. We can use associativity to compose
them first; it is often useful to be able to apply a single matrix if, for example, we want to use it to
transform many points at once.
 Important: order matters! Matrix multiplication is NOT commutative.
 Be sure to check out the Transformation Game at
http://www.cs.brown.edu/exploratories/freeSoftware/repository/edu/brown/cs/exploratories/
applets/transformationGame/transformation_game_guide.html
 Let’s see an example…





























 










1100
00
00
100
0cossin
0sincos
100
10
01
y
x
s
s
dy
dx
y
x


CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 28/45
Not commutative
0
1
1
2
2
3 4 5 6 7 8 9 10
3
4
5
6
Y
X
0
1
1
2
2
3 4 5 6 7 8 9 10
3
4
5
6
Translate by
x = 6, y = 0, then
rotate by 45o
Rotate by 45o,
then translate
by x = 6, y = 0
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
 Start: Goal:
 Important concept: make the problem simpler
 Translate object to origin first, scale, rotate, and translate back:
 Apply to all vertices
9/30/14 29/45
Composition (an example) (2D) (1/2)
T-1
RST =
1 0 3
0 1 3
0 0 1
é
ë
ê
ê
ê
ù
û
ú
ú
ú
cos90 -sin90 0
sin90 cos90 0
0 0 1
é
ë
ê
ê
ê
ù
û
ú
ú
ú
4 0 0
0 4 0
0 0 1
é
ë
ê
ê
ê
ù
û
ú
ú
ú
1 0 -3
0 1 -3
0 0 1
é
ë
ê
ê
ê
ù
û
ú
ú
ú
-Rotate 90o
-Uniform scale 4x
-Both around object’s
center, not the origin
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 30/45
Composition (an example) (2D) (2/2)
 T-1RST
 But what if we mixed up the
order? Let’s try RT-1ST:
 Oops! We scaled properly, but
when we rotated the object, it’s
center was not at the origin, so its
position was shifted. Order
matters!









































 
100
310
301
100
040
004
100
310
301
100
090cos90sin
090sin90cos
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 31/45
Aside: Skewing/shearing
Y
X0
1
1
2
2
3 4 5 6 7 8 9 10
3
4
5
6

4

 









10
tan
1
1
Skew
2D non-homogeneous















100
010
0
tan
1
1

Skew
2D homogeneous
 “Skew” an object to the side, like shearing a card
deck by displacing each card relative to the
previous one
 What physical situations mirror this behavior?
 Squares become parallelograms; x-coordinates
skew to right, y stays the same
 Notice that the base of the house (at y = 1)
remains horizontal but shifts right. Why?
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 32/45
Inverses Revisited
 What is the inverse of a sequence of transformations?
 (M1M2…Mn)-1 = Mn
-1Mn-1
-1…M1
-1
 Inverse of a sequence of transformations is the composition of the inverses of
each transformation in reverse order (why?)
 Say we want to do the opposite transformation of the example on slide 27.
What will our sequence look like?
 (T-1RST)-1 = T-1S-1R-1T
 We still translate to the origin first, then translate back at the end!












































100
310
301
100
090cos90sin
090sin90cos
100
03/10
003/1
100
310
301
TRST 1-1-1-
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
 Windowing transformation maps contents of 2D clip rectangle (“window”) to a
“viewport” rectangle on the screen, e.g., interior canvas (“client area”) of a window
manager’s window; also called window-to-viewport transformation
 Sends rectangle with bounding coordinates (u1 , vi), (u2 , v2) to (x1 , y1), (x2 , y2)
 The transformation matrix here is:
9/30/14 33/45
Aside: Windowing Transformations (CG terminology)












100
)/()()/()(0
)/()(0)/()(
1212211212
1212211212
vvvyvyvvyy
uuuxuxuuxx
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
 We understand linear transformations as changing the position of vertices
relative to the standard axes
 Can also think of transforming the coordinate axes themselves
 Just as in matrix composition, be careful of which order you modify your
coordinate system
9/30/14 34/45
Aside: Transforming Coordinate Axes
Rotation Scaling Translation
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 35/45
Dimension++ (3D!)
 How should we treat geometric transformations in 3D?
 Just add one more coordinate/axis!
 A point is represented as
 A matrix for a linear transformation T can be represented as
where e3 is the standard basis vector along the z-axis,
 But remember to use homogeneous coordinates! Embed scale and rotation
matrices as upper left submatrices and translation vectors as upper right
subvectors of the right column
T(e1) T(e2) T(e3)[ ]










z
y
x










1
0
0
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 36/45
Transformations in 3D
Transformation Matrix Comments
Scaling Looks just like the 2D version.
We just added an sz term.
Rotation (see next slide) In 2D, only one axis of
rotation; now there are
infinitely many! Must take all
into account. See next slide...
Translation Similar to the 2D version, just
with one more entry dz,
representing change in the z-
direction.












1000
000
000
000
z
y
x
s
s
s












1000
100
010
001
dz
dy
dx
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 37/45
Rodrigues’s Formula…
 Rotation by angle θ around vector u = [ux uy uz]T
 Note: this is an arbitrary unit vector u in xyz-space
 Here’s a not so friendly rotation matrix
 This is called the coordinate form of Rodrigues’s formula
 Let’s try a different approach…













)cos1(cossin)cos1(sin)cos1(
sin)cos1()cos1(cossin)cos1(
sin)cos1(sin)cos1()cos1(cos
2
2
2



zxzyyzx
xzyyzyx
yzxzyxx
uuuuuuu
uuuuuuu
uuuuuuu
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
 Every rotation can be represented as the composition of 3 different angles of counter-clockwise
rotation around 3 axes, namely
 x axis in the yz plane by ψ; y axis in the xz plane by θ; z axis in the xy plane by ϕ
 Also known as Euler angles, make problem of rotation much easier
 Note these differ only in how the 3x3 submatrix is embedded in the homogeneous matrix, but the
row-column order is different for Rzx
 You can compose these matrices to form a composite rotation matrix
9/30/14 38/45
Rotating axis by axis (1/2)
Ryz(ψ): rotation about
x axis by ψ
Rzx(θ): rotation about
y axis by θ
Rxy(ϕ): rotation about
z axis by ϕ
cosf -sinf 0 0
sinf cosf 0 0
0 0 1 0
0 0 0 1
é
ë
ê
ê
ê
ê
ê
ù
û
ú
ú
ú
ú
ú
1 0 0 0
0 cosy -siny 0
0 siny cosy 0
0 0 0 1
é
ë
ê
ê
ê
ê
ê
ù
û
ú
ú
ú
ú
ú
cosq 0 sinq 0
0 1 0 0
-sinq 0 cosq 0
0 0 0 1
é
ë
ê
ê
ê
ê
ù
û
ú
ú
ú
ú
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 39/45
Rotating axis by axis (2/2)
 It would still be difficult to find the 3 angles to
rotate by, given arbitrary axis u and specified angle ψ
 Solution? Make the problem easier by
mapping u to one of the principal axes
 Step 1: Find a θ to rotate around y axis
to put u in the xy plane
 Step 2: Then find a ϕ to rotate around
the z axis to align u with the x axis
Now that u is in a convenient alignment, we can do our transformation rotation for vertex v:
 Step 3: Rotate v by ψ around x axis (which is coincident with u axis)
 Step 4: Finally, undo the alignment rotations (inverse).
The only rotation we’ve preserved is the one around axis u by ψ, which was our goal
 Rotation matrix: M = Rzx
-1(θ)Rxy
-1(ϕ)Ryz(ψ)Rxy(ϕ)Rzx(θ)
x
y
z
θ
ϕ
u
u
v
ψ
v
v
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
 Inverses are once again parallel to their 2D versions…
 Composition works exactly the same way…
9/30/14 40/45
Inverses and Composition in 3D!
Transformation Inverse Matrix
Scaling
Rotation Ryz
-1 (ψ) Rzx
-1(θ) Rxy
-1(ϕ)
Translation












1000
0/100
00/10
000/1
z
y
x
s
s
s















1000
100
010
001
dz
dy
dx
























 













1000
0100
00cossin
00sincos
,
1000
0cos0sin
0010
0sin0cos
,
1000
0cossin0
0sincos0
0001






CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 41/45
Example in 3D!
 Let’s take some 3D object, say a cube centered at (2,2,2)
 Rotate in object’s space by 30o around x axis, 60o around y, and 90o around z
 Scale in object space by 1 in the x, 2 in the y, 3 in the z
 Translate by (2,2,4) in world space
 Transformation sequence: TT0
-1SxyRxyRzxRyzTo, where T0 translates to (0,0):







































 

















































1000
2100
2010
2001
1000
030cos30sin0
030sin30cos0
0001
1000
060cos060sin
0010
060sin060cos
1000
0100
0090cos90sin
0090sin90cos
1000
0300
0020
0001
1000
2100
2010
2001
1000
4100
2010
2001
T T0
-1 Sxy Rxy Rzx Ryz T0
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
 Objects are typically composites:
 3D scenes are often stored in a directed acyclic graph (DAG) called a scene graph
 WPF (Windows Presentation Foundation)
 Open Scene Graph (used in the Cave)
 X3D ™ (VRML ™ was a precursor to X3D)
 most game engines
 Typical scene graph format:
 objects (cubes, sphere, cone, polyhedra etc.):
 stored as nodes (default: unit size at origin)
 attributes (color, texture map, etc.): stored as separate nodes
 Transformations: also nodes
9/30/14 42/45
Transformations and the scene graph (1/5)
ROBOT
upper body lower body
head
base
Scene Graph
stanchion
trunk arm
arm
Example scenegraph from a game engine
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
 For your assignments use simplified format:
 Attributes stored as a components of each object node (no separate attribute
node)
 A transform node affects its subtree
 Only leaf nodes are graphical objects.
 All internal nodes that are not transform nodes are object group nodes
9/30/14 43/45
Transformations and the scene graph (2/5)
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 44/45
Transformations and the scene graph (3/5)
Represents a
transformation
 Step 1: Various transformations are applied to each of the leaves
(object primitives—head, base, etc.)
 Step 2: Transformations are then applied to groups of objects (form
upper and lower body, etc…)
This format means that instead of
designing new primitives for
every single shape we need, we
can just apply transformations to
a smaller set of primitives to form
complex composite 3D shapes.
Together the above hierarchy of transformations forms the “robot” scene as a whole
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 45/45
Transformations and the scene graph (4/5)
object nodes (geometry)
transformation nodes
group nodes
 A cumulative transformation matrix (CTM)
builds as you move up the tree.
 Note that higher level transformation matrices
are appended to the front of the sequence
 Example:
 For object 1 (o1), CTM = M1
 For o2, CTM = M2M3
 For o3, CTM = M2M4M5
 For a vertex v in o3, position in world coordinate system
is CTM v = (M2M4M5) v
M1 M2
M3 M4
M5
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam © 9/30/14 46/45
Transformations and the scene graph (5/5)
group3
obj3 obj4
root
group1
obj1 group3 group2
group3obj2
 You can easily reuse groups of
objects (sub-trees in the scene
graph) if they have been defined
already
 This might occur if you have multiple
similar components to your scene.
For example, the robot’s 2 arms
 Here, group 3 has been used twice.
 Transformations defined within
group 3 itself do not change; there
are different CTMs for each use of
group 3 as a whole
 T0T1 vs. T0T2T4
T0
T1
T2
T3 T4
T5 T6
CS123 | INTRODUCTION TO COMPUTER GRAPHICS
Andries van Dam ©
 More information can be found in the textbook
 Read Chapters 10 and 11 for more detail and advanced topics on
transformations
 Chapter 7 discusses the 2D/3D coordinate space geometry
 Chapter 12 goes into more detail about some of the linear algebra
involved in graphics
9/30/14 47/45
Further Reading

More Related Content

Similar to Transformations advanced

2-Vector.pptx
2-Vector.pptx2-Vector.pptx
2-Vector.pptxssfasf
 
Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks
Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeksBeginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks
Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeksJinTaek Seo
 
19 fat- craft-10-sep-2020 material-ii_10-sep-2020_craft_-_cr_-_exercise-solution
19 fat- craft-10-sep-2020 material-ii_10-sep-2020_craft_-_cr_-_exercise-solution19 fat- craft-10-sep-2020 material-ii_10-sep-2020_craft_-_cr_-_exercise-solution
19 fat- craft-10-sep-2020 material-ii_10-sep-2020_craft_-_cr_-_exercise-solutionsouvik33and37
 
Part 2- Transformation.pptx
Part 2- Transformation.pptxPart 2- Transformation.pptx
Part 2- Transformation.pptxKhalil Alhatab
 
Part 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptxPart 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptxKhalil Alhatab
 
3 d scaling and translation in homogeneous coordinates
3 d scaling and translation in homogeneous coordinates3 d scaling and translation in homogeneous coordinates
3 d scaling and translation in homogeneous coordinatesKRIPA SHNAKAR TIWARI
 
2 d transformation
2 d transformation2 d transformation
2 d transformationAnkit Garg
 
Part 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptxPart 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptxKhalil Alhatab
 
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringGraph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringSaurabh Kaushik
 
Computer graphic
Computer graphicComputer graphic
Computer graphicnusratema1
 
Normalization cross correlation value of
Normalization cross correlation value ofNormalization cross correlation value of
Normalization cross correlation value ofeSAT Publishing House
 
Computer Graphics & linear Algebra
Computer Graphics & linear Algebra Computer Graphics & linear Algebra
Computer Graphics & linear Algebra Xad Kuain
 
GTU LAVC Line Integral,Green Theorem in the Plane, Surface And Volume Integra...
GTU LAVC Line Integral,Green Theorem in the Plane, Surface And Volume Integra...GTU LAVC Line Integral,Green Theorem in the Plane, Surface And Volume Integra...
GTU LAVC Line Integral,Green Theorem in the Plane, Surface And Volume Integra...Panchal Anand
 
Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)
Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)
Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)Kyuseok Hwang(allosha)
 
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeksBeginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeksJinTaek Seo
 

Similar to Transformations advanced (20)

2-Vector.pptx
2-Vector.pptx2-Vector.pptx
2-Vector.pptx
 
Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks
Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeksBeginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks
Beginning direct3d gameprogrammingmath06_transformations_20161019_jintaeks
 
19 fat- craft-10-sep-2020 material-ii_10-sep-2020_craft_-_cr_-_exercise-solution
19 fat- craft-10-sep-2020 material-ii_10-sep-2020_craft_-_cr_-_exercise-solution19 fat- craft-10-sep-2020 material-ii_10-sep-2020_craft_-_cr_-_exercise-solution
19 fat- craft-10-sep-2020 material-ii_10-sep-2020_craft_-_cr_-_exercise-solution
 
Complex Integral
Complex IntegralComplex Integral
Complex Integral
 
Part 2- Transformation.pptx
Part 2- Transformation.pptxPart 2- Transformation.pptx
Part 2- Transformation.pptx
 
Part 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptxPart 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptx
 
3 d scaling and translation in homogeneous coordinates
3 d scaling and translation in homogeneous coordinates3 d scaling and translation in homogeneous coordinates
3 d scaling and translation in homogeneous coordinates
 
2 d transformation
2 d transformation2 d transformation
2 d transformation
 
Part 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptxPart 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptx
 
3 D Graphics
3 D Graphics3 D Graphics
3 D Graphics
 
Webdec2
Webdec2Webdec2
Webdec2
 
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph ColouringGraph Theory,Graph Terminologies,Planar Graph & Graph Colouring
Graph Theory,Graph Terminologies,Planar Graph & Graph Colouring
 
Computer graphic
Computer graphicComputer graphic
Computer graphic
 
Normalization cross correlation value of
Normalization cross correlation value ofNormalization cross correlation value of
Normalization cross correlation value of
 
Computer Graphics & linear Algebra
Computer Graphics & linear Algebra Computer Graphics & linear Algebra
Computer Graphics & linear Algebra
 
GTU LAVC Line Integral,Green Theorem in the Plane, Surface And Volume Integra...
GTU LAVC Line Integral,Green Theorem in the Plane, Surface And Volume Integra...GTU LAVC Line Integral,Green Theorem in the Plane, Surface And Volume Integra...
GTU LAVC Line Integral,Green Theorem in the Plane, Surface And Volume Integra...
 
paper
paperpaper
paper
 
2d Transformation.pdf
2d Transformation.pdf2d Transformation.pdf
2d Transformation.pdf
 
Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)
Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)
Shaderx5 2.6normalmappingwithoutprecomputedtangents 130318 (1)
 
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeksBeginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
Beginning direct3d gameprogrammingmath03_vectors_20160328_jintaeks
 

More from AVINASH JURIANI

Matlab Master Class-Day 28.Learn (1).pptx
Matlab Master Class-Day 28.Learn (1).pptxMatlab Master Class-Day 28.Learn (1).pptx
Matlab Master Class-Day 28.Learn (1).pptxAVINASH JURIANI
 
Internship Training Report
Internship Training ReportInternship Training Report
Internship Training ReportAVINASH JURIANI
 
Ict in-schools-inspectorate-evaluation-studies
Ict in-schools-inspectorate-evaluation-studiesIct in-schools-inspectorate-evaluation-studies
Ict in-schools-inspectorate-evaluation-studiesAVINASH JURIANI
 
Integer Programming, Gomory
Integer Programming, GomoryInteger Programming, Gomory
Integer Programming, GomoryAVINASH JURIANI
 
Plate Cutting Error in Fabrication Shop & their Remedial Measure with Indust...
Plate Cutting Error in Fabrication Shop & their  Remedial Measure with Indust...Plate Cutting Error in Fabrication Shop & their  Remedial Measure with Indust...
Plate Cutting Error in Fabrication Shop & their Remedial Measure with Indust...AVINASH JURIANI
 
casting sand, properties graphs
casting sand, properties graphscasting sand, properties graphs
casting sand, properties graphsAVINASH JURIANI
 
Electrochemical Machining
Electrochemical MachiningElectrochemical Machining
Electrochemical MachiningAVINASH JURIANI
 
OPTIMIZATION OF MACHINING PARAMETERS WITH TOOL INSERT SELECTION FOR S355J2G3 ...
OPTIMIZATION OF MACHINING PARAMETERS WITH TOOL INSERT SELECTION FOR S355J2G3 ...OPTIMIZATION OF MACHINING PARAMETERS WITH TOOL INSERT SELECTION FOR S355J2G3 ...
OPTIMIZATION OF MACHINING PARAMETERS WITH TOOL INSERT SELECTION FOR S355J2G3 ...AVINASH JURIANI
 
Tungsten Inert Gas Welding
Tungsten Inert Gas WeldingTungsten Inert Gas Welding
Tungsten Inert Gas WeldingAVINASH JURIANI
 
Casting Defects Analysis in Foundry and Their Remedial Measures with Industri...
Casting Defects Analysis in Foundry and Their Remedial Measures with Industri...Casting Defects Analysis in Foundry and Their Remedial Measures with Industri...
Casting Defects Analysis in Foundry and Their Remedial Measures with Industri...AVINASH JURIANI
 
OPTIMIZATION OF PLATE CUTTING LAYOUT TO MINIMIZE OFFCUT - SCRAP USING EXPERTI...
OPTIMIZATION OF PLATE CUTTING LAYOUT TO MINIMIZE OFFCUT - SCRAP USING EXPERTI...OPTIMIZATION OF PLATE CUTTING LAYOUT TO MINIMIZE OFFCUT - SCRAP USING EXPERTI...
OPTIMIZATION OF PLATE CUTTING LAYOUT TO MINIMIZE OFFCUT - SCRAP USING EXPERTI...AVINASH JURIANI
 
MULTIOBJECTIVE OPTIMIZATION OF MACHINING PARAMETERSFOR C-65 MATERIAL USING TA...
MULTIOBJECTIVE OPTIMIZATION OF MACHINING PARAMETERSFOR C-65 MATERIAL USING TA...MULTIOBJECTIVE OPTIMIZATION OF MACHINING PARAMETERSFOR C-65 MATERIAL USING TA...
MULTIOBJECTIVE OPTIMIZATION OF MACHINING PARAMETERSFOR C-65 MATERIAL USING TA...AVINASH JURIANI
 

More from AVINASH JURIANI (16)

Matlab Master Class-Day 28.Learn (1).pptx
Matlab Master Class-Day 28.Learn (1).pptxMatlab Master Class-Day 28.Learn (1).pptx
Matlab Master Class-Day 28.Learn (1).pptx
 
Internship Training Report
Internship Training ReportInternship Training Report
Internship Training Report
 
Robotics done
Robotics doneRobotics done
Robotics done
 
Ict in-schools-inspectorate-evaluation-studies
Ict in-schools-inspectorate-evaluation-studiesIct in-schools-inspectorate-evaluation-studies
Ict in-schools-inspectorate-evaluation-studies
 
IPV6 INTRODUCTION
IPV6 INTRODUCTIONIPV6 INTRODUCTION
IPV6 INTRODUCTION
 
Integer Programming, Gomory
Integer Programming, GomoryInteger Programming, Gomory
Integer Programming, Gomory
 
Plate Cutting Error in Fabrication Shop & their Remedial Measure with Indust...
Plate Cutting Error in Fabrication Shop & their  Remedial Measure with Indust...Plate Cutting Error in Fabrication Shop & their  Remedial Measure with Indust...
Plate Cutting Error in Fabrication Shop & their Remedial Measure with Indust...
 
casting sand, properties graphs
casting sand, properties graphscasting sand, properties graphs
casting sand, properties graphs
 
Electrochemical Machining
Electrochemical MachiningElectrochemical Machining
Electrochemical Machining
 
Hot Rolling Process
Hot Rolling ProcessHot Rolling Process
Hot Rolling Process
 
OPTIMIZATION OF MACHINING PARAMETERS WITH TOOL INSERT SELECTION FOR S355J2G3 ...
OPTIMIZATION OF MACHINING PARAMETERS WITH TOOL INSERT SELECTION FOR S355J2G3 ...OPTIMIZATION OF MACHINING PARAMETERS WITH TOOL INSERT SELECTION FOR S355J2G3 ...
OPTIMIZATION OF MACHINING PARAMETERS WITH TOOL INSERT SELECTION FOR S355J2G3 ...
 
Slotting machine
Slotting machineSlotting machine
Slotting machine
 
Tungsten Inert Gas Welding
Tungsten Inert Gas WeldingTungsten Inert Gas Welding
Tungsten Inert Gas Welding
 
Casting Defects Analysis in Foundry and Their Remedial Measures with Industri...
Casting Defects Analysis in Foundry and Their Remedial Measures with Industri...Casting Defects Analysis in Foundry and Their Remedial Measures with Industri...
Casting Defects Analysis in Foundry and Their Remedial Measures with Industri...
 
OPTIMIZATION OF PLATE CUTTING LAYOUT TO MINIMIZE OFFCUT - SCRAP USING EXPERTI...
OPTIMIZATION OF PLATE CUTTING LAYOUT TO MINIMIZE OFFCUT - SCRAP USING EXPERTI...OPTIMIZATION OF PLATE CUTTING LAYOUT TO MINIMIZE OFFCUT - SCRAP USING EXPERTI...
OPTIMIZATION OF PLATE CUTTING LAYOUT TO MINIMIZE OFFCUT - SCRAP USING EXPERTI...
 
MULTIOBJECTIVE OPTIMIZATION OF MACHINING PARAMETERSFOR C-65 MATERIAL USING TA...
MULTIOBJECTIVE OPTIMIZATION OF MACHINING PARAMETERSFOR C-65 MATERIAL USING TA...MULTIOBJECTIVE OPTIMIZATION OF MACHINING PARAMETERSFOR C-65 MATERIAL USING TA...
MULTIOBJECTIVE OPTIMIZATION OF MACHINING PARAMETERSFOR C-65 MATERIAL USING TA...
 

Recently uploaded

Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgsaravananr517913
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHC Sai Kiran
 
lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxsomshekarkn64
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm Systemirfanmechengr
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptMadan Karki
 

Recently uploaded (20)

Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfgUnit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
Unit7-DC_Motors nkkjnsdkfnfcdfknfdgfggfg
 
Introduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECHIntroduction to Machine Learning Unit-3 for II MECH
Introduction to Machine Learning Unit-3 for II MECH
 
lifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptxlifi-technology with integration of IOT.pptx
lifi-technology with integration of IOT.pptx
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
Class 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm SystemClass 1 | NFPA 72 | Overview Fire Alarm System
Class 1 | NFPA 72 | Overview Fire Alarm System
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.ppt
 

Transformations advanced

  • 1. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © By Avinash Juriani M.Tech IIT ISM DHN B.Tech SRM Chennai M.Tech Notes Advanced Robotics 9/30/14 1/46 Transformations
  • 2. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Geometric Transformations 2D and 3D 9/30/14 2/45
  • 3. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam ©  Objects in a scene at the lowest level are a collection of vertices…  These objects have location, orientation, size  Correspond to transformations: Translation (T), Rotation (R), and Scaling (S) 9/30/14 3/45 How do we use Geometric Transformations? (1/2)
  • 4. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam ©  A scene has a camera/view point from which the scene is viewed  The camera has some location and some orientation in 3-space …  These correspond to Translation and Rotation transformations  Need other types of viewing transformations as well - learn about them shortly 9/30/14 4/45 How do we use Geometric Transformations? (2/2)
  • 5. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 5/45 Some Linear Algebra Concepts...  3D coordinate geometry  Vectors in 2 space and 3 space  Dot product and cross product – definitions and uses  Vector and matrix notation and algebra  Identity matrix  Multiplicative associativity  E.g. A(BC) = (AB)C  Matrix transpose and inverse – definition, use, and calculation  Homogeneous coordinates (x, y, z, w) You will need to understand these concepts! Linear algebra help session notes: http://cs.brown.edu/courses/cs123/resources/Linear_Algebra.pdf
  • 6. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 6/45 Linear Transformations (1/3)  We represent vectors as bold-italic letters (v) and scalars as italic letters (c)  Any vector in the plane can be defined as the sum of two non-collinear basis vectors  Recall that a basis for a vector space is a set of vectors with the following properties: 1. The vectors in the set are linearly independent 2. Any vector in the vector space can be expressed as a linear combination of the basis vectors  Multiplying a vector by a scalar changes the vector’s magnitude v = a + bv b a
  • 7. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 7/45 Linear Transformations (2/3)  Definition of a linear function f:  f(v+w) = f(v) + f(w) for all v and w in the domain of f  f(cv) = cf(v) for all scalars c and elements v in the domain  Example: f(x) = f(x1 , x2) := (3x1+2x2 , -3x1+4x2)  Now let v and w be two elements in the domain of f  f(v+w) = f(v1+w1 , v2+w2) = (3(v1+w1)+2(v2+w2) , -3(v1+w1)+4(v2+w2)) = (3v1+2v2 , -3v1+4v2) + (3w1+2w2 , -3w1+4w2) = f(v) + f(w)  We can check the second property the same way  Both properties must be satisfied for the function f to be linear e1 e2 f(e1) f(e2)
  • 8. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam ©  Graphical use: transformations of points around the origin (leaves the origin invariant)  These include Scaling and Rotations  Translation is not a linear function (moves the origin)  Any linear transformation of a point will result in another point in the same coordinate system, transformed about the origin  Aside: How do we know the origin is invariant from the definition of linearity? 9/30/14 8/45 Linear Transformations (3/3)
  • 9. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 9/45 Linear Transformations as Matrices (1/2)  Linear transformations can be represented as invertible (non-singular) matrices  Let’s start with 2D transformations. These can be represented by 2x2 matrices:  A transformation of an arbitrary column vector x = has the form: T = a b c d é ë ê ù û ú       2 1 x x                           21 21 2 1 2 1 dxcx bxax x x dc ba x x T
  • 10. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 10/45 Linear Transformations as Matrices (2/2)  Let e1 and e2 be the standard basis vectors:  Now substitute each basis vector for x to get:  Notice that the columns of the matrix representation of our transformation matrix T are precisely T applied to e1 and e2:  This gives us a strategy for deriving transformation matrices!  We can derive the columns of a transformation matrix one by one by considering how our desired transformation affects each of the standard unit vectors.                         c a dc ba T 0 1 0 1                         d b dc ba T 1 0 1 0 e1 = 1 0 é ë ê ù û ú, e2 = 0 1 é ë ê ù û ú T(e1) = a c é ë ê ù û ú, T(e2 ) = b d é ë ê ù û ú
  • 11. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © • 9/30/14 11/45 Scaling in 2D (1/2) Side effect: House shifts position relative to origin  Scale x by 3, y by 2 (Sx = 3, Sy = 2)  v = (original vertex); v’ = (new vertex)  v’ = Sv  Derive S by determining how e1 and e2 should be transformed  (scale in X by Sx)  (scale in Y by Sy)  Thus we obtain       y x       ' ' y x        y x s s S 0 0       1 3       2 6       2 9 • 2 1 é ë ê ù û ú
  • 12. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 12/45 Scaling in 2D (2/2)  S is a diagonal matrix; we can quickly check using matrix multiplication that our derivation is correct:  S multiplies each coordinate of v by the appropriate scaling factor, as expected  In general, the ith entry of Dv, where D is diagonal, is (D[i,i] * v[i])                          ' ' 0 0 y x ys xs y x s s y x y x Sv  Properties of scaling to look out for:  Does not preserve angles between lines in the plane (except when scaling is uniform, i.e. sx = sy)  If the object doesn’t start at the origin, scaling will move it closer to or farther from the origin (often not desired)
  • 13. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 13/45 Rotation in 2D (1/2)  Rotate by θ about the origin  v’ = Sv, where  v = (original vertex)  v’ = (new vertex)  Derive Rθ by determining how e1 and e2 should be transformed:  (first column of Rθ)  (second column of Rθ)       y x        ' ' y x Þ Rq = cosq -sinq sinq cosq é ë ê ù û ú
  • 14. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 14/45 Rotation in 2D (2/2)  Let’s try matrix-vector multiplication  Rθ * v =    Other properties of rotation:  Preserves lengths in objects and angles between parts of objects (rigid-body rotation)  For objects not centered at the origin, an unwanted translation might be introduced (rotation is always about the origin) v'                           ' ' cossin sincos cossin sincos y x yx yx y x     x'= xcosq - ysinq y'= xsinq + ycosq
  • 15. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 15/45 What about translation?  If we could treat all transformations in a consistent manner, i.e., with matrix representation, then could combine transformations by composing their matrices  Let’s try using a matrix again  How? Homogeneous Coordinates: add an additional dimension, the w- axis, and an extra coordinate, the w- component  Thus 2D -> 3D (effectively the hyperspace for embedding 2D space)  Translation is not a linear transformation (the origin is not invariant)  Therefore, it can’t be represented as a 2x2 invertible matrix  Question: Is there another solution?  Answer: Yes, v’ = v + t, where t =  However, using vector addition is not consistent with our method of treating transformations as matrices       dy dx
  • 16. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 16/45 Homogeneous Coordinates (1/3)  Allow expression of all three 2D transformations as 3x3 matrices  We start with the point P2d on the xy plane and apply a mapping to bring it to the w- plane in the hyperspace  P2d(x,y)  Ph(wx, wy, w), w≠0  The resulting (x’,y’) coordinates in our new point Ph are different from the original (x,y), since x’ = wx, y’ = wy  Ph(x’, y’, w), w ≠ 0
  • 17. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 17/45 Homogeneous Coordinates (2/3)  Once we have this point, we can apply a homogenized version of our T, R and S transformation matrices (next slides) to get a new point in the hyperspace  Finally, we want to obtain the corresponding point in 2D-space, so perform the inverse of the previous mapping (divide all entries by w)  The vertex v = is now represented as v =       y x           1 y x
  • 18. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 18/45 Homogeneous Coordinates (3/3)  The transformations we use will always map points in the hyperplane defined by w = 1 to other such points. (That way, we don’t have to divide by w to get our equivalent point in 2D)  In other words, we want our transformations T to map points v = to points v’ =  How do we achieve this with the matrices we have already derived?  For linear transformations (i.e. scaling and rotation), embed the existing matrix in the upper-left of a new 3x3 matrix:           1 y x           1 ' ' y x           100 0 0 dc ba
  • 19. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 19/45 Back to Translation  Our translation matrix (T) can now be represented by embedding the translation vector in the right column:  To verify that this is the right matrix, multiply it by our homogenized point:  Coordinates have been translated, and v’ is still homogeneous            100 10 01 dy dx T v'Tv                                    11100 10 01 dyy dxx y x dy dx
  • 20. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam ©  Let’s homogenize our all matrices! Doesn’t affect linearity of scaling and rotation  Our new transformation matrices look like this…  Note: These transformations are called affine transformations, which means they preserve ratios of distances between points on a straight line 9/30/14 20/45 Transformations Homogenized Transformation Matrix Scaling Rotation Translation sx 0 0 0 sy 0 0 0 1 é ë ê ê ê ê ù û ú ú ú ú cosq -sinq 0 sinq cosq 0 0 0 1 é ë ê ê ê ù û ú ú ú 1 0 dx 0 1 dy 0 0 1 é ë ê ê ê ù û ú ú ú
  • 21. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 21/45 Examples  Scaling: Scale by 15 in the x direction, 17 in the y  Rotation: Rotate by 123o  Translation: Translate by -16 in the x direction, +18 in the y            100 0)123cos()123sin( 0)123sin()123cos(           100 0170 0015             100 1810 1601
  • 22. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam ©  Up until now, we’ve only used the notion of a point in our 2D space  We now present a distinction between points and vectors  We used homogeneous coordinates to more conveniently represent translation; hence points are represented as (x, y, 1)T  A vector can be rotated/scaled, but not translated (can think of it as always starting at origin), so don’t use the homogeneous coordinate: (x, y, 0)T  That way, the translation matrix won’t have any affect on our vectors.  For now, let’s focus on just our points (typically vertices) 9/30/14 22/45 Before we continue! Vectors vs. Points
  • 23. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam ©  When we want to undo a transformation, we’ll need to find the matrix’s inverse.  Thanks to homogenization, they are all invertible! 9/30/14 23/45 Inverses Transformation Matrix Inverse Does it make sense? Scaling If you scale something by factor a, the inverse is scaling by 1/a Rotation Inverse of rotation by θ is rotation by –θ. The properties sin(-θ) = -sin(θ) and cos(-θ) = cos(θ) give this matrix. Also, the matrix is orthonormal, so inverse is just the transpose (see next slide). Translation If you translate by x, the inverse is translation by -x
  • 24. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 24/45 A moment of appreciation for linear algebra  The inverse of a rotation matrix M is just its transpose MT! That’s really convenient, so let’s understand how it works using orthonormal matrices  Take a rotation matrix M = [v1 v2 v3] (where each vi is a vector)  First note some properties of M  The columns are orthogonal to each other: vi • vj = 0 (i ≠ j)  Columns have unit length: ||vi|| = 1  Let’s see what multiplying MT and M produces:  Using the properties above, we see that this is the identity matrix, so MT = M-1                                   332313 322212 312111 321 321 321 333 222 111 vvvvvv vvvvvv vvvvvv vvv vvv vvv vvv vvv vvv zzz yyy xxx zyx zyx zyx
  • 25. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 25/45 More with Homogeneous Coordinates Some uses we’ll see later:  Placing sub-objects in parent’s coordinate system to construct hierarchical scene graph  Transforming primitives in their own coordinate systems  View volume normalization  Mapping arbitrary view volume into canonical view volume along z-axis  Parallel (orthographic, oblique) and perspective projections  Perspective transformation (turn viewing pyramid into a cuboid to turn perspective projection into parallel projection) after perspective foreshortening
  • 26. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 26/45 Composition of Transformations (2D) (1/2)  We now have a number of tools at our disposal; we can combine them!  An object in a scene uses many transformations in sequence. How do we represent this in terms of functions?  Transformation is a function; by associativity, we can compose functions:  (f o g)( i )  This is the same as first applying g, then applying f:  f( g( i ) )  Consider our functions f and g as matrices (M1 and M2) and our input as a vector v  Our composition is equivalent to M1M2v
  • 27. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 27/45 Composition of Transformations (2D) (2/2)  We can now form compositions of transformation matrices to form a more complex transformation  For example, TRSv, which scales a point, then rotates it, then translates it:  Note that we apply the matrices in sequence right to left. We can use associativity to compose them first; it is often useful to be able to apply a single matrix if, for example, we want to use it to transform many points at once.  Important: order matters! Matrix multiplication is NOT commutative.  Be sure to check out the Transformation Game at http://www.cs.brown.edu/exploratories/freeSoftware/repository/edu/brown/cs/exploratories/ applets/transformationGame/transformation_game_guide.html  Let’s see an example…                                          1100 00 00 100 0cossin 0sincos 100 10 01 y x s s dy dx y x  
  • 28. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 28/45 Not commutative 0 1 1 2 2 3 4 5 6 7 8 9 10 3 4 5 6 Y X 0 1 1 2 2 3 4 5 6 7 8 9 10 3 4 5 6 Translate by x = 6, y = 0, then rotate by 45o Rotate by 45o, then translate by x = 6, y = 0
  • 29. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam ©  Start: Goal:  Important concept: make the problem simpler  Translate object to origin first, scale, rotate, and translate back:  Apply to all vertices 9/30/14 29/45 Composition (an example) (2D) (1/2) T-1 RST = 1 0 3 0 1 3 0 0 1 é ë ê ê ê ù û ú ú ú cos90 -sin90 0 sin90 cos90 0 0 0 1 é ë ê ê ê ù û ú ú ú 4 0 0 0 4 0 0 0 1 é ë ê ê ê ù û ú ú ú 1 0 -3 0 1 -3 0 0 1 é ë ê ê ê ù û ú ú ú -Rotate 90o -Uniform scale 4x -Both around object’s center, not the origin
  • 30. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 30/45 Composition (an example) (2D) (2/2)  T-1RST  But what if we mixed up the order? Let’s try RT-1ST:  Oops! We scaled properly, but when we rotated the object, it’s center was not at the origin, so its position was shifted. Order matters!                                            100 310 301 100 040 004 100 310 301 100 090cos90sin 090sin90cos
  • 31. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 31/45 Aside: Skewing/shearing Y X0 1 1 2 2 3 4 5 6 7 8 9 10 3 4 5 6  4             10 tan 1 1 Skew 2D non-homogeneous                100 010 0 tan 1 1  Skew 2D homogeneous  “Skew” an object to the side, like shearing a card deck by displacing each card relative to the previous one  What physical situations mirror this behavior?  Squares become parallelograms; x-coordinates skew to right, y stays the same  Notice that the base of the house (at y = 1) remains horizontal but shifts right. Why?
  • 32. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 32/45 Inverses Revisited  What is the inverse of a sequence of transformations?  (M1M2…Mn)-1 = Mn -1Mn-1 -1…M1 -1  Inverse of a sequence of transformations is the composition of the inverses of each transformation in reverse order (why?)  Say we want to do the opposite transformation of the example on slide 27. What will our sequence look like?  (T-1RST)-1 = T-1S-1R-1T  We still translate to the origin first, then translate back at the end!                                             100 310 301 100 090cos90sin 090sin90cos 100 03/10 003/1 100 310 301 TRST 1-1-1-
  • 33. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam ©  Windowing transformation maps contents of 2D clip rectangle (“window”) to a “viewport” rectangle on the screen, e.g., interior canvas (“client area”) of a window manager’s window; also called window-to-viewport transformation  Sends rectangle with bounding coordinates (u1 , vi), (u2 , v2) to (x1 , y1), (x2 , y2)  The transformation matrix here is: 9/30/14 33/45 Aside: Windowing Transformations (CG terminology)             100 )/()()/()(0 )/()(0)/()( 1212211212 1212211212 vvvyvyvvyy uuuxuxuuxx
  • 34. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam ©  We understand linear transformations as changing the position of vertices relative to the standard axes  Can also think of transforming the coordinate axes themselves  Just as in matrix composition, be careful of which order you modify your coordinate system 9/30/14 34/45 Aside: Transforming Coordinate Axes Rotation Scaling Translation
  • 35. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 35/45 Dimension++ (3D!)  How should we treat geometric transformations in 3D?  Just add one more coordinate/axis!  A point is represented as  A matrix for a linear transformation T can be represented as where e3 is the standard basis vector along the z-axis,  But remember to use homogeneous coordinates! Embed scale and rotation matrices as upper left submatrices and translation vectors as upper right subvectors of the right column T(e1) T(e2) T(e3)[ ]           z y x           1 0 0
  • 36. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 36/45 Transformations in 3D Transformation Matrix Comments Scaling Looks just like the 2D version. We just added an sz term. Rotation (see next slide) In 2D, only one axis of rotation; now there are infinitely many! Must take all into account. See next slide... Translation Similar to the 2D version, just with one more entry dz, representing change in the z- direction.             1000 000 000 000 z y x s s s             1000 100 010 001 dz dy dx
  • 37. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 37/45 Rodrigues’s Formula…  Rotation by angle θ around vector u = [ux uy uz]T  Note: this is an arbitrary unit vector u in xyz-space  Here’s a not so friendly rotation matrix  This is called the coordinate form of Rodrigues’s formula  Let’s try a different approach…              )cos1(cossin)cos1(sin)cos1( sin)cos1()cos1(cossin)cos1( sin)cos1(sin)cos1()cos1(cos 2 2 2    zxzyyzx xzyyzyx yzxzyxx uuuuuuu uuuuuuu uuuuuuu
  • 38. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam ©  Every rotation can be represented as the composition of 3 different angles of counter-clockwise rotation around 3 axes, namely  x axis in the yz plane by ψ; y axis in the xz plane by θ; z axis in the xy plane by ϕ  Also known as Euler angles, make problem of rotation much easier  Note these differ only in how the 3x3 submatrix is embedded in the homogeneous matrix, but the row-column order is different for Rzx  You can compose these matrices to form a composite rotation matrix 9/30/14 38/45 Rotating axis by axis (1/2) Ryz(ψ): rotation about x axis by ψ Rzx(θ): rotation about y axis by θ Rxy(ϕ): rotation about z axis by ϕ cosf -sinf 0 0 sinf cosf 0 0 0 0 1 0 0 0 0 1 é ë ê ê ê ê ê ù û ú ú ú ú ú 1 0 0 0 0 cosy -siny 0 0 siny cosy 0 0 0 0 1 é ë ê ê ê ê ê ù û ú ú ú ú ú cosq 0 sinq 0 0 1 0 0 -sinq 0 cosq 0 0 0 0 1 é ë ê ê ê ê ù û ú ú ú ú
  • 39. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 39/45 Rotating axis by axis (2/2)  It would still be difficult to find the 3 angles to rotate by, given arbitrary axis u and specified angle ψ  Solution? Make the problem easier by mapping u to one of the principal axes  Step 1: Find a θ to rotate around y axis to put u in the xy plane  Step 2: Then find a ϕ to rotate around the z axis to align u with the x axis Now that u is in a convenient alignment, we can do our transformation rotation for vertex v:  Step 3: Rotate v by ψ around x axis (which is coincident with u axis)  Step 4: Finally, undo the alignment rotations (inverse). The only rotation we’ve preserved is the one around axis u by ψ, which was our goal  Rotation matrix: M = Rzx -1(θ)Rxy -1(ϕ)Ryz(ψ)Rxy(ϕ)Rzx(θ) x y z θ ϕ u u v ψ v v
  • 40. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam ©  Inverses are once again parallel to their 2D versions…  Composition works exactly the same way… 9/30/14 40/45 Inverses and Composition in 3D! Transformation Inverse Matrix Scaling Rotation Ryz -1 (ψ) Rzx -1(θ) Rxy -1(ϕ) Translation             1000 0/100 00/10 000/1 z y x s s s                1000 100 010 001 dz dy dx                                        1000 0100 00cossin 00sincos , 1000 0cos0sin 0010 0sin0cos , 1000 0cossin0 0sincos0 0001      
  • 41. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 41/45 Example in 3D!  Let’s take some 3D object, say a cube centered at (2,2,2)  Rotate in object’s space by 30o around x axis, 60o around y, and 90o around z  Scale in object space by 1 in the x, 2 in the y, 3 in the z  Translate by (2,2,4) in world space  Transformation sequence: TT0 -1SxyRxyRzxRyzTo, where T0 translates to (0,0):                                                                                           1000 2100 2010 2001 1000 030cos30sin0 030sin30cos0 0001 1000 060cos060sin 0010 060sin060cos 1000 0100 0090cos90sin 0090sin90cos 1000 0300 0020 0001 1000 2100 2010 2001 1000 4100 2010 2001 T T0 -1 Sxy Rxy Rzx Ryz T0
  • 42. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam ©  Objects are typically composites:  3D scenes are often stored in a directed acyclic graph (DAG) called a scene graph  WPF (Windows Presentation Foundation)  Open Scene Graph (used in the Cave)  X3D ™ (VRML ™ was a precursor to X3D)  most game engines  Typical scene graph format:  objects (cubes, sphere, cone, polyhedra etc.):  stored as nodes (default: unit size at origin)  attributes (color, texture map, etc.): stored as separate nodes  Transformations: also nodes 9/30/14 42/45 Transformations and the scene graph (1/5) ROBOT upper body lower body head base Scene Graph stanchion trunk arm arm Example scenegraph from a game engine
  • 43. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam ©  For your assignments use simplified format:  Attributes stored as a components of each object node (no separate attribute node)  A transform node affects its subtree  Only leaf nodes are graphical objects.  All internal nodes that are not transform nodes are object group nodes 9/30/14 43/45 Transformations and the scene graph (2/5)
  • 44. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 44/45 Transformations and the scene graph (3/5) Represents a transformation  Step 1: Various transformations are applied to each of the leaves (object primitives—head, base, etc.)  Step 2: Transformations are then applied to groups of objects (form upper and lower body, etc…) This format means that instead of designing new primitives for every single shape we need, we can just apply transformations to a smaller set of primitives to form complex composite 3D shapes. Together the above hierarchy of transformations forms the “robot” scene as a whole
  • 45. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 45/45 Transformations and the scene graph (4/5) object nodes (geometry) transformation nodes group nodes  A cumulative transformation matrix (CTM) builds as you move up the tree.  Note that higher level transformation matrices are appended to the front of the sequence  Example:  For object 1 (o1), CTM = M1  For o2, CTM = M2M3  For o3, CTM = M2M4M5  For a vertex v in o3, position in world coordinate system is CTM v = (M2M4M5) v M1 M2 M3 M4 M5
  • 46. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © 9/30/14 46/45 Transformations and the scene graph (5/5) group3 obj3 obj4 root group1 obj1 group3 group2 group3obj2  You can easily reuse groups of objects (sub-trees in the scene graph) if they have been defined already  This might occur if you have multiple similar components to your scene. For example, the robot’s 2 arms  Here, group 3 has been used twice.  Transformations defined within group 3 itself do not change; there are different CTMs for each use of group 3 as a whole  T0T1 vs. T0T2T4 T0 T1 T2 T3 T4 T5 T6
  • 47. CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam ©  More information can be found in the textbook  Read Chapters 10 and 11 for more detail and advanced topics on transformations  Chapter 7 discusses the 2D/3D coordinate space geometry  Chapter 12 goes into more detail about some of the linear algebra involved in graphics 9/30/14 47/45 Further Reading