cse3431-lecture5.key
Hierarchical structures
Wrist and 5 fingers
We want the fingers to stay
attached to the wrist as the
wrist moves.
Each segment is abstracted
by a coordinate system and
has its own transformation
matrix with respect to its
parent’s system thus
modelling relative motion.
Wrist
F1_1
F1_2
F1_3
Hierarchy of systems
Wrist
F1_1
F1_2
F1_3
Wrist T1_1
F1_1 T1_2
Twrist
F1_2 T1_3
F1_3
CSwrist
CSwolrd
Hierarchy of systems
CSF1_1 = T1_1(CSwrist)
CSF1_2 = T1_2(CSF1_1)
CSF1_3 = T1_3(CSF1_2)
F1_1
F1_2
F1_3
CSwrist
CSwolrd
Wrist
Example: Kinematic Chain
Pw = wMAAMBBMCPC
What do these matrices look like?
CSA CSB CSC
CSW
Example: Kinematic Chain
Pw = wMAAMBBMCPC
What do these matrices look like?
Depends on the structure and the
degrees of freedom we want
CSA CSB CSC
CSW
Example: Kinematic Chain
Pw = wMAAMBBMCPC
One possibility (three degrees of freedom)
CSA CSB CSC
CSW
Pw(✓1, ✓2, ✓3) =
(T (1, 1)R(z, ✓1))(T (1, 0)R(z, ✓2))(T (2, 0)R(z, ✓3))Pc
Example: Kinematic Chain
CSA
CSB
CSC
CSW
Pw(10, 10, 10) =
(T (1, 1)R(z, 10))(T (1, 0)R(z, 10))(T (2, 0)R(z, 10))Pc
How is each part drawn in code?
CSA CSB CSC
CSW
T (1, 1) ModelMat = T (1, 1)
R(z, ✓1) ModelMat = T (1, 1)R(z, ✓1)
drawCube() Cube size 1 centered at the origin
T (1, 0) ModelMat = T (1, 1)R(z, ✓1)T (1, 0)
R(z, ✓2) ModelMat = T (1, 1)R(z, ✓1)T (1, 0)R(z, ✓2)
drawCube()
T (2, 0) ModelMat = T (1, 1)R(z, ✓1)T (1, 0)R(z, ✓2)T (2, 0)
R(z, ✓3) ModelMat = T (1, 1)R(z, ✓1)T (1, 0)R(z, ✓2)T (2, 0)Rz(✓3)
dawCube()
How is each part drawn?
CSA CSB CSC
CSW
T (1, 1) ModelMat = T (1, 1)
R(z, ✓1) ModelMat = T (1, 1)R(z, ✓1)
drawCube() Cube size 1 centered at the origin
T (1, 0) ModelMat = T (1, 1)R(z, ✓1)T (1, 0)
R(z, ✓2) ModelMat = T (1, 1)R(z, ✓1)T (1, 0)R(z, ✓2)
drawCube()
T (2, 0) ModelMat = T (1, 1)R(z, ✓1)T (1, 0)R(z, ✓2)T (2, 0)
R(z, ✓3) ModelMat = T (1, 1)R(z, ✓1)T (1, 0)R(z, ✓2)T (2, 0)Rz(✓3)
dawCube()
How we get this?
CSA CSB CSC
CSW
Let’s look at the first link
CSACSA
CSW CSW
T (1, 1) M = T (1, 1)
R(z, ✓1) M = T (1, 1)R(z, ✓1)
drawCube() Cube size 1 centered at the origin
T (1, 1) M = T (1, 1)
R(z, ✓1) M = T (1, 1)R(z, ✓1)
T (0.5, 0) M = T (1, 1)R(z, ✓1)T (0.5, 0)
S(1, 0.3) M = T (1, 1)R(z, ✓1)T (0.5, 0)S(1, 0.3)
drawCube() Cube size 1 centered at the origin
Let’s look at the second link
CSA
CSW This is a problem now!
It should only apply to the first
cube,
not the second system. I could
undo the transformations.
However,
CSB
T (1, 1) M = T (1, 1)
R(z, ✓1) M = T (1, 1)R(z, ✓1)
T (0.5, 0) M = T (1, 1)R(z, ✓1)T (0.5, 0)
S(1, 0.3) M = T (1, 1)R(z, ✓1)T (0.5, 0)S(1, 0.3)
drawCube() Cube size 1 centered at the origin
Matrix Stack
When we have more than one branch or
multiple objects, it is often convenient to use
a matrix stack to load and unload matrices
• Using the push(*) and pop() operations of a stack
• stack.push(M); // in the code gPush()
• draw();
• stack.pop(M); // in the code gPop()
Using the stack
CSA
CSW
CSB
stack.init() [ ]
T (1, 1) [M = T (1, 1)]
R(z, ✓1) [M = T (1, 1)R(z, ✓1)]
stack.push() [M,M ]
T (0.5, 0) [M = T (1, 1)R(z, ✓1),M
0 = MT (0.5, 0)]
S(1, 0.3) [M = T (1, 1)R(z, ✓1),M
0 = MT (0.5, 0)S(1, 0.3)]
drawCube() Cube size 1 centered at the origin
stack.pop() [M = T (1, 1)R(z, ✓1)]
Hybrid way of thinking
Use TOP to BOTTOM to position a
coordinate system
Then use BOTTOM to TOP to position the
objects within that system
Often it is easier to do it in the opposite
order
Graphics Pipeline
Modelling
transformation
Viewing
transformation
Projection
transformation
Perspective
division
Viewport
transformation
OCS WCS VCS CCS
NDCS
DCS
M-1cam
Taking a snapshot of a 3D Scene
Image copyright E. Angel
OpenGL Assumption
The camera system is:
Camera transformation
Transforms objects to camera coordinates
OpenGL Modelview matrix
Defining Mcam
Common way
Eye point
Reference point
Upvector
To build Mcam we need to define a camera coordinate
system (origin, i, j, k)
Camera Coordinate system
Building Mcam
Change of basis
Our reference system is WCS,
we know the camera parameters with
respect to the world
Align WCS with VCS
VCS
WCS
Peye x
y
z
Building Mcam inverse
Invert smart
Building Mcam inverse
Invert smart
Transpose
Camera Transform
Summary
• The camera transformation is really another affine
transformation
• It transforms the scene so that the camera is at zero
looking down the -z axis
x
y
End of Modelling transformations
1. Preservation of affine combinations of points.
2. Preservation of lines and planes.
3. Preservation of parallelism of lines and planes.
4. Relative ratios on a line are preserved
5. Affine transformations are composed of
elementary ones.
Camera transformation as a change of basis.
Graphics Pipeline
Modelling
transformation
Viewing
transformation
Projection
transformation
Perspective
division
Viewport
transformation
OCS WCS VCS CCS
NDCS
DCS
M-1cam