Computer Graphics: Local Space, World Space and Cameras
Computer Graphics: Local Space, World Space and Cameras
Computer Graphics: Local Space, World Space and Cameras
Ciencia de la Computación
ICC Fase 1
Computer graphics
Local space, world space and
cameras
2 Projection matrices
The perspective projection matrix
The orthographic projection matrix
Look-at matrix
vmachacaa@unsa.edu.pe
Table of Contents
2 Projection matrices
The perspective projection matrix
The orthographic projection matrix
Look-at matrix
vmachacaa@unsa.edu.pe
The matrix that positions and orients an object into world space
is called a model matrix, or M.
vmachacaa@unsa.edu.pe
Table of Contents
2 Projection matrices
The perspective projection matrix
The orthographic projection matrix
Look-at matrix
vmachacaa@unsa.edu.pe
Camera
Camera
OpenGL includes a camera that is permanently fixed at the
origin (0, 0, 0).
vmachacaa@unsa.edu.pe
Camera in OpenGL
Camera in OpenGL
Cw .
Camera in OpenGL
Camera in OpenGL
We can build a single transform that does both the rotation (R)
and the translation (T) in one matrix, called the viewing
transform matrix (V).
PC = R ∗ (T ∗ PW ) (1)
PC = (R ∗ T ) ∗ PW (2)
PC = V ∗ PW (3)
vmachacaa@unsa.edu.pe
Camera in OpenGL
Deriving a view matrix
Camera in OpenGL
Model and View Matrices
MV = V ∗ M (4)
vmachacaa@unsa.edu.pe
Camera in OpenGL
Model and View Matrices
MV = V ∗ M (4)
PC = MV ∗ PM (5)
vmachacaa@unsa.edu.pe
Table of Contents
2 Projection matrices
The perspective projection matrix
The orthographic projection matrix
Look-at matrix
vmachacaa@unsa.edu.pe
Perspective projection
attempts to make a 2D picture
appear 3D.
no longer parallel.
1
q= (6)
fieldOfView
tan( )
2
q
A= (7)
aspectRatio Figure: Perspective matrix.
Znear + Zfar
B= (8)
Znear − Zfar
The GLM library includes a
vmachacaa@unsa.edu.pe
glm::perspective() for
2 ∗ (Znear ∗ Zfar ) building a perspective matrix.
C= (9)
Znear − Zfar
Table of Contents
2 Projection matrices
The perspective projection matrix
The orthographic projection matrix
Look-at matrix
vmachacaa@unsa.edu.pe
Parameters:
Znear
Zfar
L and R: X coordinates of
left and right boundaries
of the projection plane.
T and B: Y coordinates of
top and bottom
boundaries of the Figure: Orthographic projection
matrix.
projection plane.
vmachacaa@unsa.edu.pe
Table of Contents
2 Projection matrices
The perspective projection matrix
The orthographic projection matrix
Look-at matrix
vmachacaa@unsa.edu.pe
Look-at matrix
This is handy when you wish to place the camera at one location
and look toward a particular other location.
vmachacaa@unsa.edu.pe
Look-at matrix
References I
Questions?
vmachacaa@unsa.edu.pe