![Page 1: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/1.jpg)
University of British ColumbiaCPSC 314 Computer Graphics
Jan-Apr 2010
Tamara Munzner
http://www.ugrad.cs.ubc.ca/~cs314/Vjan2010
Transformations III
Week 3, Mon Jan 18
![Page 2: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/2.jpg)
2
News
• CS dept announcements
• Undergraduate Summer Research Award(USRA)• applications due Feb 26• see Guiliana for more details
![Page 3: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/3.jpg)
3
Department of Computer ScienceUndergraduate Events
Events this weekDrop-in Resume/Cover Letter EditingDate: Tues., Jan 19Time: 12:30 – 2 pmLocation: Rm 255, ICICS/CS Bldg.
Interview Skills WorkshopDate: Thurs., Jan 21Time: 12:30 – 2 pmLocation: DMP 201Registration: Email [email protected]
Project Management WorkshopSpeaker: David Hunter (ex-VP, SAP)Date: Thurs., Jan 21Time: 5:30 – 7 pmLocation: DMP 110
CSSS Laser TagDate: Sun., Jan 24Time: 7 – 9 pmLocation: Planet Laser @ 100 Braid St., New
Westminster
Event next weekPublic Speaking 11Date: Mon., Jan 25Time: 5 – 6 pmLocation: DMP 101
![Page 4: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/4.jpg)
4
Assignments
![Page 5: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/5.jpg)
5
Assignments• project 1
• out today, due 5pm sharp Fri Jan 29• projects will go out before we’ve covered all the material
• so you can think about it before diving in
• build iguana out of cubes and 4x4 matrices• think cartoon, not beauty
• template code gives you program shell, Makefile• http://www.ugrad.cs.ubc.ca/~cs314/Vjan2010/p1.tar.gz
• written homework 1• out today, due 5pm sharp Wed Feb 6• theoretical side of material
![Page 6: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/6.jpg)
6
Demo
• animal out of boxes and matrices
![Page 7: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/7.jpg)
7
Real Iguanas
http://www.naturephoto-cz.com/photos/sevcik/green-iguana--iguana-iguana-1.jpg
jpg
http://www.mccullagh.org/db9/d30-3/iguana-closeup.jpg
http://funkman.org/animal/reptile/iguana1.jpg
![Page 8: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/8.jpg)
8
Armadillos!
![Page 9: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/9.jpg)
9
Armadillos!
![Page 10: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/10.jpg)
10
Monkeys!
![Page 11: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/11.jpg)
11
Monkeys!
![Page 12: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/12.jpg)
12
Giraffes!
![Page 13: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/13.jpg)
13
Giraffes!
![Page 14: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/14.jpg)
14
Project 1 Advice• do not model everything first and only then
worry about animating• interleave modelling, animation
• for each body part: add it, then jumpcutanimate, then smooth animate
• discover if on wrong track sooner• dependencies: can’t get anim credit if no
model• use body as scene graph root
• check from all camera angles
![Page 15: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/15.jpg)
15
Project 1 Advice
• finish all required parts before• going for extra credit• playing with lighting or viewing
• ok to use glRotate, glTranslate, glScale• ok to use glutSolidCube, or build your own
• where to put origin? your choice• center of object, range - .5 to +.5• corner of object, range 0 to 1
![Page 16: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/16.jpg)
16
Project 1 Advice
• visual debugging• color cube faces differently• colored lines sticking out of glutSolidCube
faces• make your cubes wireframe to see inside
• thinking about transformations• move physical objects around• play with demos
• Brown scenegraph applets
![Page 17: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/17.jpg)
17
Project 1 Advice
• smooth transition• change happens gradually over X frames• key click triggers animation• one way: redraw happens X times
• linear interpolation: each time, param += (new-old)/30
• or redraw happens over X seconds• even better, but not required
![Page 18: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/18.jpg)
18
Project 1 Advice
• transitions• safe to linearly interpolate parameters for
glRotate/glTranslate/glScale• do not interpolate individual elements of 4x4
matrix!
![Page 19: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/19.jpg)
19
Style• you can lose up to 15% for poor style• most critical: reasonable structure
• yes: parametrized functions• no: cut-and-paste with slight changes
• reasonable names (variables, functions)• adequate commenting
• rule of thumb: what if you had to fix a bug twoyears from now?
• global variables are indeed acceptable
![Page 20: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/20.jpg)
20
Version Control• bad idea: just keep changing same file• save off versions often
• after got one thing to work, before you try starting somethingelse
• just before you do something drastic• how?
• not good: commenting out big blocks of code• a little better: save off file under new name
• p1.almostworks.cpp, p1.fixedbug.cpp
• much better: use version control software• strongly recommended
![Page 21: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/21.jpg)
21
Version Control Software• easy to browse previous work• easy to revert if needed• for maximum benefit, use meaningful comments to describe
what you did• “started on tail”, “fixed head breakoff bug”, “leg code compiles but
doesn’t run”• useful when you’re working alone• critical when you’re working together• many choices: RCS, CVS, svn/subversion
• all are installed on lab machines• svn tutorial is part of next week’s lab
![Page 22: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/22.jpg)
22
Graphical File Comparison
• installed on lab machines• xfdiff4 (side by side comparison)• xwdiff (in-place, with crossouts)
• Windows: windiff• http://keithdevens.com/files/windiff
• Macs: FileMerge• in /Developer/Applications/Utilities
![Page 23: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/23.jpg)
23
Readings for Transformations I-IV• FCG Chap 6 Transformation Matrices
• except 6.1.6, 6.3.1• FCG Sect 13.3 Scene Graphs• RB Chap Viewing
• Viewing and Modeling Transforms until Viewing Transformations• Examples of Composing Several Transformations through
Building an Articulated Robot Arm• RB Appendix Homogeneous Coordinates and Transformation
Matrices• until Perspective Projection
• RB Chap Display Lists
![Page 24: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/24.jpg)
24
Review: Shear, Reflection• shear along x axis
• push points to right in proportion to height
• reflect across x axis• mirror
x
y
x
y
!"
#$%
&+!"
#$%
&!"
#$%
&=!
"
#$%
&
'
'
0
0
10
1
y
xsh
y
x x
!"
#$%
&+!"
#$%
&!"
#$%
&
'=!
"
#$%
&
(
(
0
0
10
01
y
x
y
x
x x
![Page 25: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/25.jpg)
25
Review: 2D Transformations
!"
#$%
&=!
"
#$%
&
+
+=!
"
#$%
&+!"
#$%
&
'
'
y
x
by
ax
b
a
y
x
( ) ( )( ) ( ) !
"
#$%
&!"
#$%
& '=!
"
#$%
&
y
x
y
x
((
((
cossin
sincos
'
'
!"
#$%
&!"
#$%
&=!
"
#$%
&
y
x
b
a
y
x
0
0
'
'
scaling matrix rotation matrix
!"
#$%
&=!
"
#$%
&!"
#$%
&
'
'
y
x
y
x
dc
ba
translation multiplication matrix??
vector addition
matrix multiplicationmatrix multiplication
),( ba(x,y)
(x′,y′)
![Page 26: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/26.jpg)
26
Review: Linear Transformations• linear transformations are combinations of
• shear• scale• rotate• reflect
• properties of linear transformations• satisifes T(sx+ty) = s T(x) + t T(y)• origin maps to origin• lines map to lines• parallel lines remain parallel• ratios are preserved• closed under composition
!"
#$%
&!"
#$%
&=!
"
#$%
&
y
x
dc
ba
y
x
'
'
dycxy
byaxx
+=
+=
'
'
![Page 27: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/27.jpg)
27xxyy
ww
w=w=11
Review: Homogeneous Coordinates
• point in 2D cartesian + weight w =point P in 3D homog. coords• multiples of (x,y,w) form 3D line L• all homogeneous points on L
represent same 2D cartesian point• homogenize to convert homog. 3D
point to cartesian 2D point:• divide by w to get (x/w, y/w, 1)• projects line to point onto w=1 plane• like normalizing, one dimension up
),,( wyx
homogeneoushomogeneous
),(w
y
w
x
cartesiancartesian
/ w/ w
!
x
y
1
"
#
$ $ $
%
&
' ' ' !
x " w
y " w
w
#
$
% % %
&
'
( ( (
![Page 28: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/28.jpg)
28
Review: Homogeneous Coordinates• 2D transformation matrices are now 3x3:
!!!
"
#
$$$
%
& '
=
100
0)cos()sin(
0)sin()cos(
((
((
otationR
!!!
"
#
$$$
%
&
=
100
00
00
b
a
caleS
!!!
"
#
$$$
%
&
=
100
10
01
y
x
T
T
ranslationT
!!!
"
#
$$$
%
&
+
+
=
!!!
"
#
$$$
%
&
'+'
'+'
=
!!!
"
#
$$$
%
&
!!!
"
#
$$$
%
&
11
11
11
1100
10
01
by
ax
by
ax
y
x
b
a
use rightmost column!
![Page 29: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/29.jpg)
29
Review: Affine Transformations• affine transforms are combinations of
• linear transformations• translations
• properties of affine transformations• origin does not necessarily map to origin• lines map to lines• parallel lines remain parallel• ratios are preserved• closed under composition
!!!
"
#
$$$
%
&
!!!
"
#
$$$
%
&
=
!!!
"
#
$$$
%
&
w
y
x
fed
cba
w
y
x
100
'
'
![Page 30: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/30.jpg)
30
Review: 3D Transformations
!!!!
"
#
$$$$
%
&
!!!!
"
#
$$$$
%
&
=
!!!!
"
#
$$$$
%
&
11
1
1
1
1
'
'
'
z
y
x
c
b
a
z
y
x
translate(a,b,c)translate(a,b,c)
!!!!
"
#
$$$$
%
&
!!!!
"
#
$$$$
%
&
'=
!!!!
"
#
$$$$
%
&
11
cossin
sincos
1
1
'
'
'
z
y
x
z
y
x
((
((
),(Rotate !x
!!!!
"
#
$$$$
%
&
!!!!
"
#
$$$$
%
&
=
!!!!
"
#
$$$$
%
&
111
'
'
'
z
y
x
c
b
a
z
y
x
scale(a,b,c)scale(a,b,c)
!!!!
"
#
$$$$
%
&
'
1
cossin
1
sincos
((
((
),(Rotate !y
!!!!
"
#
$$$$
%
& '
1
1
cossin
sincos
((
((
),(Rotate !z
!
1 hyx hzx 0
hxy 1 hzy 0
hxz hyz 1 0
0 0 0 1
"
#
$ $ $ $
%
&
' ' ' '
shear(shear(hxyhxy,,hxzhxz,,hyxhyx,,hyzhyz,,hzxhzx,,hzyhzy))
![Page 31: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/31.jpg)
31
Review: Composing Transformations
Ta Tb = Tb Ta, but RaTa Tb = Tb Ta, but Ra Rb Rb !=!= Rb Rb Ra and TaRa and Ta Rb Rb !=!= Rb Rb TaTa• translations commute• rotations around same axis commute• rotations around different axes do not commute• rotations and translations do not commute
![Page 32: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/32.jpg)
32
!
p'= TRp
Review: Composing Transformations
• which direction to read?• right to left
• interpret operations wrt fixed coordinates• moving object
• left to right• interpret operations wrt local coordinates• changing coordinate system• OpenGL updates current matrix with postmultiply
• glTranslatef(2,3,0);• glRotatef(-90,0,0,1);• glVertexf(1,1,1);
• specify vector last, in final coordinate system• first matrix to affect it is specified second-to-last
OpenGL pipeline ordering!
![Page 33: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/33.jpg)
33
!
p'= TRp
More: Composing Transformations
• which direction to read?• right to left
• interpret operations wrt fixed coordinates• moving object
• draw thing• rotate thing by -90 degrees wrt origin• translate it (-2, -3) over
![Page 34: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/34.jpg)
34
!
p'= TRp
More: Composing Transformations
• which direction to read?• left to right
• interpret operations wrt local coordinates• changing coordinate system
• translate coordinate system (2, 3) over• rotate coordinate system 90 degrees wrt origin• draw object in current coordinate system
• in OpenGL, cannot move object once it is drawn!!
![Page 35: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/35.jpg)
35
General Transform Composition
• transformation of geometry into coordinatesystem where operation becomes simpler• typically translate to origin
• perform operation
• transform geometry back to originalcoordinate system
![Page 36: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/36.jpg)
36
Rotation About an Arbitrary Axis
• axis defined by two points• translate point to the origin• rotate to align axis with z-axis (or x or y)• perform rotation• undo aligning rotations• undo translation
![Page 37: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/37.jpg)
Arbitrary Rotation
• arbitrary rotation: change of basis• given two orthonormal coordinate systems XYZ and ABC
• A’s location in the XYZ coordinate system is (ax, ay, az, 1), ...
Y
ZX
B
C
A
![Page 38: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/38.jpg)
Arbitrary Rotation
• arbitrary rotation: change of basis• given two orthonormal coordinate systems XYZ and ABC
• A’s location in the XYZ coordinate system is (ax, ay, az, 1), ...
Y
ZX
B
C
A
Y
ZX
B
C
A
(cx, cy, cz, 1)
(ax, ay, az, 1)(bx, by, bz, 1)
![Page 39: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/39.jpg)
Arbitrary Rotation
• arbitrary rotation: change of basis• given two orthonormal coordinate systems XYZ and ABC
• A’s location in the XYZ coordinate system is (ax, ay, az, 1), ...
• transformation from one to the other is matrix R whosecolumns are A,B,C:
Y
ZX
B
C
A
Y
ZX
B
C
A
(cx, cy, cz, 1)
(ax, ay, az, 1)(bx, by, bz, 1)
!
R(X) =
ax bx cx 0
ay by cy 0
az bz cz 0
0 0 0 1
"
#
$ $ $ $
%
&
' ' ' '
1
0
0
1
"
#
$ $ $ $
%
&
' ' ' '
= (ax,ay,az,1) = A
![Page 40: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/40.jpg)
40
Transformation Hierarchies
![Page 41: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/41.jpg)
41
Transformation Hierarchies
• scene may have a hierarchy of coordinatesystems• stores matrix at each level with incremental
transform from parent’s coordinate system
• scene graph roadroad
stripe1stripe1 stripe2stripe2 ...... car1car1 car2car2 ......
w1w1 w3w3w2w2 w4w4
![Page 42: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/42.jpg)
42
Transformation Hierarchy Example 1
torsotorso
headheadRUarmRUarm
RLarmRLarm
RhandRhand
RUlegRUleg
RLlegRLleg
RfootRfoot
LUarmLUarm
LLarmLLarm
LhandLhand
LUlegLUleg
LLlegLLleg
LfootLfoot
worldworld
trans(0.30,0,0) rot(z, )trans(0.30,0,0) rot(z, )!
![Page 43: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/43.jpg)
43
Transformation Hierarchy Example 2
• draw same 3D data with differenttransformations: instancing
![Page 44: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/44.jpg)
44
Transformation Hierarchies Demo
• transforms apply to graph nodes beneath
http://www.http://www.cscs.brown..brown.edu/exploratories/freeSoftware/catalogs/edu/exploratories/freeSoftware/catalogs/scenegraphsscenegraphs.html.html
![Page 45: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/45.jpg)
45
Transformation Hierarchies Demo
• transforms apply to graph nodes beneath
http://www.http://www.cscs.brown..brown.edu/exploratories/freeSoftware/catalogs/edu/exploratories/freeSoftware/catalogs/scenegraphsscenegraphs.html.html
![Page 46: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/46.jpg)
46
Matrix Stacks
• challenge of avoiding unnecessarycomputation• using inverse to return to origin• computing incremental T1 -> T2
Object coordinatesObject coordinates
World coordinatesWorld coordinates
TT11(x)(x) TT22(x)(x)TT33(x)(x)
![Page 47: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/47.jpg)
47
Matrix Stacks
glPushMatrixglPushMatrix()()
glPopMatrixglPopMatrix()()AA
BB
CC
AA
BB
CC
AA
BB
CC
CC
glScale3f(2,2,2)glScale3f(2,2,2)
D = C scale(2,2,2) trans(1,0,0)D = C scale(2,2,2) trans(1,0,0)
AA
BB
CC
DD
DrawSquareDrawSquare()()glTranslate3f(1,0,0)glTranslate3f(1,0,0)
DrawSquareDrawSquare()()
glPushMatrixglPushMatrix()()
glPopMatrixglPopMatrix()()
![Page 48: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/48.jpg)
48
Modularization
• drawing a scaled square• push/pop ensures no coord system change
voidvoid drawBlock drawBlock(float k) {(float k) { glPushMatrix glPushMatrix();();
glScalef glScalef(k,k,k);(k,k,k); glBegin glBegin(GL_LINE_LOOP);(GL_LINE_LOOP); glVertex3f(0,0,0); glVertex3f(0,0,0); glVertex3f(1,0,0); glVertex3f(1,0,0); glVertex3f(1,1,0); glVertex3f(1,1,0); glVertex3f(0,1,0); glVertex3f(0,1,0); glEnd glEnd();();
glPopMatrix glPopMatrix();();}}
![Page 49: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/49.jpg)
49
Matrix Stacks• advantages
• no need to compute inverse matrices all the time• modularize changes to pipeline state• avoids incremental changes to coordinate systems
• accumulation of numerical errors
• practical issues• in graphics hardware, depth of matrix stacks is limited
• (typically 16 for model/view and about 4 for projective matrix)
![Page 50: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/50.jpg)
50
Transformation Hierarchy Example 3
FFWW
FFhh
FFhh
glLoadIdentityglLoadIdentity();();glTranslatefglTranslatef(4,1,0);(4,1,0);glPushMatrixglPushMatrix();();glRotatefglRotatef(45,0,0,1);(45,0,0,1);glTranslatefglTranslatef(0,2,0);(0,2,0);glScalefglScalef(2,1,1);(2,1,1);glTranslateglTranslate(1,0,0);(1,0,0);glPopMatrixglPopMatrix();();
FF11
FF hh
FF hh
FF hh
FF hh
FFhh
![Page 51: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/51.jpg)
51
Transformation Hierarchy Example 4
4!
1!5
! 3!
2!
xx
yy
glTranslate3f(x,y,0);glTranslate3f(x,y,0);glRotatefglRotatef( ,0,0,1);( ,0,0,1);DrawBodyDrawBody();();glPushMatrixglPushMatrix();(); glTranslate3f(0,7,0); glTranslate3f(0,7,0); DrawHeadDrawHead();();glPopMatrixglPopMatrix();();glPushMatrixglPushMatrix();(); glTranslateglTranslate(2.5,5.5,0);(2.5,5.5,0); glRotatefglRotatef( ,0,0,1);( ,0,0,1); DrawUArmDrawUArm();(); glTranslateglTranslate(0,-3.5,0);(0,-3.5,0); glRotatefglRotatef( ,0,0,1);( ,0,0,1); DrawLArmDrawLArm();();glPopMatrixglPopMatrix();();... (draw other arm)... (draw other arm)
1!
2!
3!
![Page 52: Transformations III Week 3, Mon Jan 18tmm/courses/314/Vjan2010/slides/week3.day1.pdfTransformations III Week 3, Mon Jan 18. 2 News •CS dept announcements ... 16 Project 1 Advice](https://reader035.vdocuments.net/reader035/viewer/2022070815/5f0f45e77e708231d443577a/html5/thumbnails/52.jpg)
52
Hierarchical Modelling• advantages
• define object once, instantiate multiple copies• transformation parameters often good control knobs• maintain structural constraints if well-designed
• limitations• expressivity: not always the best controls• can’t do closed kinematic chains
• keep hand on hip• can’t do other constraints
• collision detection• self-intersection• walk through walls