# CS代考计算机代写 Computer Graphics CSI4130 – Winter 2019

Computer Graphics CSI4130 – Winter 2019
Jochen Lang

This Lecture
• Projections
– Textbook:Chapter4.7 – Orthographicprojection – Perspective projection
CSI4130 Computer Graphics

Canonical Viewing Volume
– Canonical viewing volume is a cube with side length 2 centered at origin
• BUT scene may be defined at other location with other dimensions
– Transformation from Canonical Viewing Volume into the window can be defined in 3D
Maps the canonical view volume into screen coordinates
CSI4130 Computer Graphics

Orthographic Projection
– Projects the viewing volume from somewhere along the negative z-axis to the canonical viewing volume.
– Maps a rectangular volume into a cube • translate and scale
• use 3D transformations
– Orthographicprojectiondisregardsthe distance of objects from the viewer
• useful in engineering drawings to generate front, top and side view of objects
CSI4130 Computer Graphics
Source: Wikimedia

Example:
Orthographic Projection
• Rendering of a 3D Scan of a ceramic dish
CSI4130 Computer Graphics

Orthographic Projection
Camera position
3D Object
Parallel viewing rays
Image plane
– Viewing rays are orthogonal to image
– Preserves distances independent of viewing depth
CSI4130 Computer Graphics

Orthographic Projection – OpenGL Viewing Matrix
top plane t
optical axis: negative z direction bottom plane b
image plane
right plane r left plane l far plane f near plane n = image plane
glOrtho( l, r, b, t, |n|, |f| )
Translation and scaling to cube of side-length of 2
CSI4130 Computer Graphics

Orthographic Projection
• Fixed pipeline used glProjection matrix stack and the commands glOrtho and gluOrtho2d
• OpenGL Today
– Free to use whatever is convenient. We use glm in the lab
• implements setting a matrix as in opengl calls (does not use the fixed pipeline with its projection matrix stack).
glm::mat4 Projection = glm::ortho(l,r,b,t); – Near is set to -1 and far to 1 as in gluOrtho2d
glm::mat4 Projection =
glm::ortho( l,r,b,t,n,f)
CSI4130 – Computer Graphics

WebGL and Three.js
• glMatrix.js provides
ortho(out, left, right, bottom, top, near, far)
• Three.js has both a camera object
– OrthographicCamera( left, right, top, bottom,
near, far )
– Note that for some bottom and top are flipped!
It also provides the corresponding call in Matrix4 to just set a matrix.
CSI4130 Computer Graphics

3D Window Transform
Dropping
results in continuous coordinate images of size 2.0×2.0
CSI4130 Computer Graphics

Flipping the Z-axis
• Consider that OpenGL works with a flipped z-axis – The image plane is at .
􏰤􏰅􏰥􏰇􏰣􏰦􏰧
Maps n to 1 and f to -1
glOrtho( l, r, b, t, |n|, |f| )
CSI4130 Computer Graphics

Orthographic Projection into Viewport
• Consider mapping from canonical viewing volume into the viewport
– window coordinates
􏰎􏰎􏰎 􏰏􏰏􏰏
CSI4130 Computer Graphics

Perspective
Source: Wikimedia
CSI4130 Computer Graphics

Historical Perspective
Source: Wikimedia
CSI4130 Computer Graphics

Perspective Projection
• Cameras and eyes can be approximated by a camera pinhole model.
• In2D:
Source: Wikimedia
CSI4130 Computer Graphics

Perspective Projection is Important
• Distance from viewer determines image size
• Examples:
1,435 mm
– Airporttunnel
Source: Wikimedia
CSI4130 Computer Graphics

Another Example
– Cube under perspective projection
– Vanishing points (Parallel line on a tilted plane intersect not at infinity).
vanishing point 2
vanishing point 1
image plane
Wikimedia
center of projection
CSI4130 Computer Graphics
Source:

Effect of Focal Length
– Zoom lenses have a large focal length
– Wide angle lenses have a short focal length
Source: Wikimedia
CSI4130 Computer Graphics

Next Lecture
• Textbook: Chapter 4.7
• OpenGL projection matrix
• Camera modelling
CSI4130 Computer Graphics