Graphics Slides 02
Graphics Slides 02
In order to represent planar polygons in the computer Wire frame models simply include points and lines.
we will require a mixture of numerical and
topological data. In order to draw a 3D wire frame model we must first
convert the points to a 2D representation. Then we
Numerical Data can use simple drawing primitives to draw them.
Actual 3D coordinates of vertices, etc.
The conversion from 3D into 2D is a form of
Topological Data projection.
Details of what is connected to what
1
Normal Orthographic Projection Orthographic Projection onto z=0
Projector
so
V+µd
x
(d=[0,0,-1)
All projectors have direction d = [0,0,-1]
Projector Equation:
P=V+µd
Substitute d = [0,0,-1] Looking at a Face General View
Yields cartesian form
Px = Vx + 0 Py = Vy + 0 Pz = Vz - µ
The projection plane is z=0 so the projected
coordinate is Looking at a vertex
[Vx,Vy,0]
ie we simply take the 3D x and y components of the
vertex
Graphics Lecture 2: Slide 9 Graphics Lecture 2: Slide 10
X
Viewpoint
Graphics Lecture 2: Slide 11 Graphics Lecture 2: Slide 12
2
Calculating Perspective Projection Perspective Projection of a Cube
Projector Equation:
7
P = µ V (all projectors go through the origin)
At the projected point Pz=f Looking at a Face General View
µp = Pz/Vz = f/Vz
Px = µp Vx and Py = µp Vy
Thus
Looking at a vertex
Px = f Vx/Vz and Py = f Vy/Vz
The constant µp is sometimes called the fore-
shortenting factor
Given that the viewpoint is at the origin, and the Graphics scenes are defined in one co-ordinate system
viewing plane is at z=5: What point on the viewplane
corresponds to the 3D vertex {10,10,10} in We want to be able to draw a graphics scene from any
a. Perspective projection angle
b. Orthographic projection
Y
For example to make an object at the origin twice as
Z
big we could use:
Z
[x',y',z'] = 2 0 0 x
0 2 0 y
X
0 0 2 z
Coordinate System for definition Coordinate System for viewing
yields
3
Translation by Matrix multiplication Honogenous Coordinates
Many of our transformations will require translation The answer is to use homogenous coordinates
of the points.
For example if we want to move all the points two
units along the x axis we would require: [x', y', z', 1] = [ x, y, z, 1] 1 0 0 0
0 1 0 0
0 0 1 0
x’ = x + 2 2 0 0 1
y’ = y
z’ = z
In most cases the last ordinate will be 1, but in general Affine transformations are those that preserve parallel
we can consider it a scale factor. lines.
4
Scaling Inverting scaling
Suppose we want to make an object at the origin We multiply out the transformation matrices first,
twice as big and then move it to a point [5, 5, 20]. then transform the points
Y Y
T * S is not the same as S * T Translate Scale
x:=x+1 x:=x*2
X X
5
Rotation Rotation Matrices
Rx = 1 0 0 0 Ry = Cos(θ) 0 -Sin(θ) 0
The simplest rotations are about the Cartesian axes 0 Cos(θ) Sin(θ) 0 0 1 0 0
0 -Sin(θ) Cos(θ) 0 Sin(θ) 0 Cos(θ) 0
0 0 0 1 0 0 0 1
eg Rz = Cos(θ) Sin(θ) 0 0
-Sin(θ) Cos(θ) 0 0
0 0 1 0
Rx - Rotate about the X axis 0 0 0 1
Rotate by θ
Rotations have a direction.
r
Sin(-θ) = -Sin(θ)