Title: Mathematical Basis for Graphics
1Mathematical Basis for Graphics
Representations in a frame Homogeneous
Coordinates
Affine Space
Scalars
Vectors
Points
Operations
Transformation
2Frames and Transformations of Representations
v is representation of a point or vector in
frame
If
then
u is representation of a point or vector in
frame
is of the form
3Instance Transformation
S
R
T
Model Coordinates
4Important Points to Know in Matrix Definition
and Manipulation
- Matrix forms for trans, scale, rot
- Concatenation of matrices
- OpenGL commands to change matrices
- Organization of matrix data structure
5How to Create 3D-Object Views?
6Classical ViewingPerspective Projection
Object
COP Center of Projection origin of camera frame
Projection Plane
COP
7Classical ViewingParallel Projection
Object
- Viewer at an infinite distance from the objects
- COP is replaced by DOP (Direction of Projection)
DOP
Projection Plane
8Examples of Classical Views
9Classical ViewingOrthographic Projection
10Classical ViewingAxonometric Projections
11Classical ViewingAxonometric Projections
- Parallel projection
- Symmetrical to principal face (PF)
General Case
Symmetric to 2PFs
Symmetric to 3 PFs
12Dimetric Projection
13Isometric Projection
14Classical ViewingOblique Projection
- General case for parallel projection
- Projector can make arbitrary angle with the
projection plan
15Classical ViewingForeshortening
Projection Plane
Object
Object size s is foreshortened to l
u
n
q
l
s
16Example in Parallel Projection
17Classical ViewingPerspective Projection
How many principal directions in the object are
parallel to the projection plane?
VP2
VP1
- 3-point perspective (none)
- 2-point perspective (one)
- 1-point perspective (two)
Perspective viewing
VP3
18Example in Perspective Projection
19Viewing in Computer GraphicsProjection Transforms
Projection Plane
T
20Front and Back Clipping Planes
21OpenGLCanonical Orthographic View Volume
y
Plane z -1
Plane z 1
x
DOP
Projection Plane
z
22Orthographic Viewing Transform
What we want
What we use
Transformation is
23General OpenGlOrthographic Projection
glOrtho(xmin, xmax, ymin, ymax, zmin, zmax)
P
Canonical view volume
24Affine Transformations for Normalization
25General OpenGLOrthographic Projection
P
Translate View Volume
Scale View Volume
26General OpenGLOrthographic Projection
P
Zeroed by postmult by
27Classical ViewingPerspective Projection
Object
Projection Plane
COP
28Perspective Projection
Parallel to the lens and orthogonal to the z-dir
More general case
3D view
Side view
Top view
29Perspective Projection (2)
Proj. Plane
Equations are non linear. Therefore cannot use
linear affine transformation.
30Whats problems in Perspective Projection??
All points along a projector project into the
same point, we cannot recover a point from its
projection Solution using homogeneous
coordinates to handle projections
31Perspective Division
Consider the transformation matrix
If we allow the form
to represent a point,
we can recover the original form by division by
w. This is called perspective division.
The transformation then yields
32Projection Pipeline
33Canonical Perspective Transformation
34Canonical Perspective TransformationIdea -
Transformation of View Volume
Orthographic projection is applied as last step
to project to plane z 0.
35(No Transcript)
36Three Steps in Determining the OpenGL Perspective
Transformation
- Shearing the window to the z-axis
- Scaling
- 3. Perspective normalization/mapping
37Shearing Transform in 2D
- Consider shear transformation matrix along x-axis
- The term a is the proportionality constant. A
point P (x,y,1) after transformation becomes - Note that x is a function of y
38Shearing Transform in 2D (cont)
- Similarly consider shear transformation matrix
along y-axis - The term b is the proportionality constant. A
point P (x,y,1) after transformation becomes - Note that y is a function of x
39Shearing Transform in 3D
- Shear transformation matrix in (x,y) plane
- A point P (x,y,z,1) after transformation
becomes - Note that x and y are functions of z
40Perspective Tx -- Shearing the window to the
z-axis
- move the ray from the origin through the window
center onto the z axis - when z -n, ?x should be (rl)/2n and ?y should
be (tb)/2n, so we getÂ
41Perspective Tx -- Shearing the window to the
z-axis
- So the shearing transformation will then be
- That means, the shearing matrix is given by
42Perspective Tx --Scaling
-
- We want the oblique clipping planes to have
- Such that with boundaries lb-n and r t n.
- This requires a scale to make the window this
size
43Perspective Tx Scaling (cont)
-
- Therefore, the scaling matrix is given by,
44Perspective Tx Perspective normalization/mapping
- We want to map the frustum to a 2x2x2 cube
centered at the orgin. First, we map the bounding
planes x ?z and y ?z to the planes x ?1 and
y ?1. This can be done by mapping x to x/-z and
y to y/-z -
45Perspective Tx Perspective normalization/mapping
-
- Ø     We use a map to homogeneous coordinates
and then project back to 3 space by dividing - Ø     Now, we need to solve a, b, c and d such
that z in -n, -f maps to z in 1,1. - Â
- Ø     As x maps to x/-z, we get
- Â Â Â Â
46Perspective Tx Perspective normalization/mapping
-
- Ø     As the near plane is at z-n and the far
plane at z-f, which map to (-1, 1) respectively,
we get    Â
47Perspective Tx Perspective normalization/mapping
-
- Ø  Thus, the perspective normalization matrix is
given by, Â Â Â
48Perspective Transformation matrix
49General OpenGL Perspective Transformation
glFrustrum(l,r,b,t,n,f)
50Canonical Transformation of View VolumeIn OpenGL
51General OpenGL Perspective TransformationAnother
form
gluPerspective(fovy, aspect, zNear, ZFar)
fovy Specifies the field of view angle in
degrees, in the y direction. aspect Specifies
the aspect ratio that determines the ratio of
width to height. zNear Specifies the distance
from the viewer to the near clipping plane,
always positive. zFar Specifies the distance
from the viewer to the far clipping plane, always
positive.
52Hidden Surface Removal(Z - Buffer Algorithm)
General Approaches Object Space
Algorithms Draw back facing polygons
first. Convex objects do not render back
facing polygons. What about front facing
polygons that obstruct each other? Image Space
Algorithms Determine relationship among points
on each projector
53Initializing Z-Buffer in OpenGL
glutInitDisplayMode(GLUT_DOUBLEGLUT_RGBGLUT_DEPT
H)
Allocates the buffer.
glEnable(GL_DEPTH_TEST)
Enables depth testing.
54Positioning the Camera
Initially, the camera is at (0,0,0) for
perspective viewing looking in the -z
direction. To move the camera away from modeled
objects distance d along the the positive z
axis glTranslatef(0.0, 0.0, -d) What you are
really doing is translating the modeled objects
in the negative z direction. If you want to look
at the model from the positive x direction at a
distance d glTranslatef(0.0, 0.0,
-d) glRotatef(-90.0, 0.0, 1.0, 0.0)
55A More Intuitive ApproachOffered by glu
gluLookAt(eyex, eyey, eyez, atx, aty, atz,
upx, upy, upz) eyex, eyey, eyez specify the
position of the eye point and are mapped to
the origin. atx, aty, atz specify a point being
looked at, which will be rendered in center of
view port. It is mapped to the -z axis. upx,
upy, upz specify components of the camera up
vector.