Mathematical Basis for Graphics - PowerPoint PPT Presentation

1 / 51
About This Presentation
Title:

Mathematical Basis for Graphics

Description:

T. Model. Coordinates. Figures are extracted from Angle's textbook. 4. 4. Important Points to Know ... Such that with boundaries l=b=-n and r = t = n. ... – PowerPoint PPT presentation

Number of Views:34
Avg rating:3.0/5.0
Slides: 52
Provided by: hughmas
Category:

less

Transcript and Presenter's Notes

Title: Mathematical Basis for Graphics


1
Mathematical Basis for Graphics
Representations in a frame Homogeneous
Coordinates
Affine Space
Scalars
Vectors
Points
Operations
Transformation
2
Frames 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
3
Instance Transformation
S
R
T
Model Coordinates
4
Important 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

5
How to Create 3D-Object Views?
6
Classical ViewingPerspective Projection
Object
COP Center of Projection origin of camera frame
Projection Plane
COP
7
Classical ViewingParallel Projection
Object
  • Viewer at an infinite distance from the objects
  • COP is replaced by DOP (Direction of Projection)

DOP
Projection Plane
8
Examples of Classical Views
9
Classical ViewingOrthographic Projection
10
Classical ViewingAxonometric Projections
11
Classical ViewingAxonometric Projections
12
Dimetric Projection
13
Isometric Projection
14
Classical ViewingForeshortening
Projection Plane
Object
Object size s is foreshortened to l
u
n
q
l
s
15
Classical ViewingPerspective Projection
VP2
VP1
  • 3-point perspective
  • 2-point perspective
  • 1-point perspective

Perspective viewing
VP3
16
Viewing in Computer GraphicsProjection Transforms
Projection Plane
T
17
Front and Back Clipping Planes
18
OpenGLCanonical Orthographic View Volume
y
Plane z -1
Plane z 1
x
DOP
Projection Plane
z
19
Orthographic Viewing Transform
What we want
What we use
Transformation is
  • Affine
  • Singular

20
General OpenGlOrthographic Projection
glOrtho(xmin, xmax, ymin, ymax, zmin, zmax)
P
Canonical view volume
21
Affine Transformations for Normalization
22
General OpenGLOrthographic Projection
P
Translate View Volume
Scale View Volume
23
General OpenGLOrthographic Projection
P
Zeroed by postmult by
24
Classical ViewingPerspective Projection
Object
Projection Plane
COP
25
Perspective Projection
Parallel to the lens and orthogonal to the z-dir
More general case
3D view
Side view
Top view
26
Perspective Projection (2)
Proj. Plane
Equations are non linear. Therefore cannot use
linear affine transformation.
27
Whats 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
28
Perspective 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
29
Projection Pipeline
30
Canonical Perspective Transformation
31
Canonical Perspective TransformationIdea -
Transformation of View Volume
Orthographic projection is applied as last step
to project to plane z 0.
32
Three Steps in Determining the OpenGL Perspective
Transformation
  • Shearing the window to the z-axis
  • Scaling
  • 3. Perspective normalization/mapping

33
Shearing 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

34
Shearing 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

35
Shearing 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

36
Perspective 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 

37
Perspective Tx -- Shearing the window to the
z-axis
  • So the shearing transformation will then be
  • That means, the shearing matrix is given by

38
Perspective 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

39
Perspective Tx Scaling (cont)
  • Therefore, the scaling matrix is given by,

40
Perspective 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

41
Perspective 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
  •     

42
Perspective 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     

43
Perspective Tx Perspective normalization/mapping
  • Ø  Thus, the perspective normalization matrix is
    given by,    

44
Perspective Transformation matrix

45
General OpenGL Perspective Transformation
glFrustrum(l,r,b,t,n,f)
46
Canonical Transformation of View VolumeIn OpenGL
After normalization, OpenGL is in left-handed 3D
normalized coordinates.
47
General 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.
48
Hidden 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
49
Initializing Z-Buffer in OpenGL
glutInitDisplayMode(GLUT_DOUBLEGLUT_RGBGLUT_DEPT
H)
Allocates the buffer.
glEnable(GL_DEPTH_TEST)
Enables depth testing.
50
Positioning 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)
51
A 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.
Write a Comment
User Comments (0)
About PowerShow.com