Geometry: �Projection
Instructor: Christopher Rasmussen (cer@cis.udel.edu)
February 25, 2021 ❖ Lecture 4
Outline
Projections in CG
Parallel Projections
3-D points "slide" along direction d until they hit plane, where their locations can be described in 2-D. For example, Q→ q, P→p *
from Hill
*not our usual notation for points
Parallel Projection subtypes
Oblique: d in general orientation
relative to image plane normal n
Orthographic: d parallel to n
from Hill
Oblique Projection: Example
Orthographic Projection
from Hill
Camera Orientation under Orthographic Projection (set by lookat)
courtesy of http://glasnost.itcarlow.ie/~powerk/GeneralGraphicsNotes/projection/orthographicprojection.html
Z
X
Y
Da Vinci's 1502 plan of Imola
Elevations, plan of Pantheon in Rome
Plan/elevation views in games (not necessarily orthographic)
Z
X
Y
Camera Orientation under Orthographic Projection (set by lookat)
By SharkD - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=8497328
These angles are not the same as Euler angles (roll, pitch, yaw) of camera. Camera angles for isometric view are explained here
Camera Orientation under Orthographic Projection (set by lookat)
some images courtesy of http://glasnost.itcarlow.ie/~powerk/GeneralGraphicsNotes/projection/orthographicprojection.html
SimCity 2000 (not quite isometric)
Diablo
Zaxxon
The Geometry Pipeline so far...
M = rotation, scaling, translation that puts model where we want it in the world
V = transformation that places the camera (the result of the lookat() function)
Model vs. World Coordinates
M = rotation, scaling, translation that puts model where we want it in the world
Z
X
Y
Z
X
Y
model frame
world frame
Model vs. World Coordinates
Mi for each pencil i to scale, rotate,
and translate it just so
Z
X
Y
world frame
image courtesy Osman Usta, S2019 student
Orthographic Projection in OpenGL
Projection in OpenGL
P = intrinsics of camera; result sometimes called "clip coordinates"
Orthographic Projection Matrix for CVV
Translation to origin followed by scaling to 2 x 2 x 2 cube
(If n & f are not distances then n > f, which is why it is
“-2/(f - n)” below — see formula in Marschner):
Orthographic Projection Matrix for CVV
Translation to origin followed by scaling to 2 x 2 x 2 cube
(If n & f are not distances then n > f, which is why it is
“-2/(f - n)” below — see formula in Marschner):
Perspective with a Pinhole Camera (i.e., no lens), aka "camera obscura"
from Forsyth & Ponce
Instead of single direction d characteristic of parallel projections,
rays emanating from single point c (or eye e) define
perspective projection
c
Stenop.es project: Apartment as pinhole camera
More Stenop.es (note projection is upside-down)
Perspective Projection
from Forsyth & Ponce
c
Contrasting VVs for perspective and orthographic projection
Issues with Real Pinhole Cameras
from https://en.wikipedia.org/wiki/Camera_lens
Perspective Projection: Viewing Volume
Perspective Projection: From Camera Coordinates to Image Coordinates
xcam
xim
Perspective Projection
Focal length
(“near” distance)
y / z = v / f and x / z = u / f, so....
v = fy / z and u = fx / z
Perspective Projection
Focal length
(“near” distance)
Perspective Projection Matrix
Last step accomplishes distance-dependent scaling by the rule for converting between homogeneous and regular coordinates. This is called the perspective division
Perspective Transformation Matrix
f does not mean
same thing here
as on previous slide!!
Perspective Transformation: Details
Perspective Projections in OpenGL
from Woo et al.
glm::perspective()
from Woo et al.
Field of View
courtesy of S. Marschner
Field of View
courtesy of S. Marschner
Closer to orthographic projection because rays are more nearly parallel
Viewport Transform
Geometry pipeline
Coordinate change rigid transform / view transform V
Perspective transform P
(and/or orthographic scaling) to CVV
2-D scale and shift
Perspective division
Orthographic projection
Camera coordinates
Clip coordinates
Normalized device coordinates
Window coordinates
Screen coordinates
World coordinates
Rotate, scale, translate with model transform M
Model coordinates
Combining Transformations: Order
Transformations with GLM
#include <glm/glm.hpp>
#include <glm/gtx/transform.hpp>� � glm::mat4 myMatrix;� glm::vec4 myVector;
// fill these somehow� glm::vec4 transformedVector = myMatrix * myVector;
More next time on OpenGL in general
Important Transformations with GLM
Model Transformations with GLM
glm::translate(glm::vec3( 3.0f,
0.0f,
0.0f));
Model Transformations with GLM
glm::rotate((float) M_PI,
glm::vec3( 0.0f,
0.0f,
1.0f));
View Transformation with GLM
glm::lookat( glm::vec3(4,3,3),
glm::vec3(0,0,0),
glm::vec3(0,1,0));
Projection Transformations with GLM
glm::perspective( 45.0f,
4.0f / 3.0f,
0.1f,
100.0f);
Homework #1
Homework #1
Homework #1
Selected HW #1 submissions (spring, 2019)
Scott Benton (440)
Osman Usta (640)