Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Graphics Toolkits
Graphics toolkits typically take care of the details
of producing images from geometry
Input:
Where the objects are located and what they look like
Where the camera is and how it behaves
Parameters for controlling the rendering
OpenGL
OpenGL is an open standard graphics toolkit
Derived from SGIs GL toolkit
Coordinate Systems
The use of coordinate systems is fundamental to
computer graphics
Coordinate systems are used to describe the
locations of points in space
Multiple coordinate systems make graphics
algorithms easier to understand and implement
(2,3)
y
u
(1,2)
u
Transformations
Transformations convert points between
coordinate systems
y
(2,3)
u
x
u=x-1
v=y-1
x=u+1
y=v+1
(1,2)
u
x
Transformations
(Alternate Interpretation)
Transformations modify an objects shape and
location in one coordinate system
(2,3)
y
x=x-1
y=y-1
x=x+1
y=y+1
(1,2)
2D Affine Transformations
An affine transformation is one that can be written
in the form:
x a xx x a xy y bx
y a yx x a yy y by
or
x a xx a xy x bx
y a a y b
yx yy y
Translation
Scaling
Rotation
Shear
Reflection
2D Translation
Moves an object
x 1 0 x bx
y 0 1 y b
y
y
by
bx
2D Scaling
Resizes an object in each dimension
x s x
y 0
y
y
0 x 0
s y y 0
y
syy
sxx
2D Rotation
Rotate counter-clockwise about the origin by an
angle
x cos
y sin
sin x 0
cos y 0
y
X-Axis Shear
Shear along x axis (What is the matrix for y axis
shear?)
x 1 sh x 0
y 0
1 y 0
x
0 x 0
1 y 0
Homogeneous Coordinates
y a
yx
1 0
xy
a yy
0
by y
1 1
Basic Transformations
cos
1 0 bx
Translation: 0 1 b y Rotation: sin
0
0 0 1
Scaling:
sx
0
0
sy
0
0
0
sin
cos
0
0
0
3D Translation
x 1
y 0
z 0
1 0
0 0 tx x
1 0 ty y
0 1 tz z
0 0 1 1
3D Rotation
Rotation in 3D is about an axis in 3D space
passing through the origin
Using a matrix representation, any matrix with an
orthonormal top-left 3x3 sub-matrix is a rotation
Rows are mutually orthogonal (0 dot product)
Determinant is 1
Implies columns are also orthogonal, and that the
transpose is equal to the inverse
3D Rotation
x rxx rxy rxz 0 x
y r
y
r
r
0
yx yy yz
z rzx rzy rzz 0 z
1 0 0 0 1 1
and for example :
rxxryx rxy ryy rxzryz 0
Alternative Representations
Specify the axis and the angle (OpenGL method)
Hard to compose multiple rotations
Quaternions
Quaternions
4-vector related to axis and angle, unit magnitude
Rotation about axis (nx,ny,nz) by angle :
nx cos / 2, n y cos / 2, nz cos / 2, sin / 2
Easy to compose
Easy to go to/from rotation matrix
See Watt section 17.2.4 and start of 17.2.5
Transformation Tidbits
Scale, shear etc extend naturally from 2D to 3D
Rotation and Translation are the rigid-body
transformations:
Do not change lengths or angles, so a body does not
deform when transformed