Download presentation
Presentation is loading. Please wait.
Published byCori Lawson Modified over 9 years ago
1
Introduction to 3D Graphics Lecture 3: General Camera Model Anthony Steed University College London
2
Overview n More Maths –Rotations and translations –Homogenous co-ordinates n General Camera –Specification –Mapping to world coordinates
3
Vectors and Matrices n Matrix is an array of numbers with dimensions M (rows) by N (columns) –3 by 6 matrix –element 2,3 is (3) is (3) n Vector can be considered a 1 x M matrix –
4
Types of Matrix n Identity matrices - I n Diagonal n Symmetric –Diagonal matrices are (of course) symmetric –Identity matrices are (of course) diagonal
5
Operation on Matrices n Addition –Done elementwise n Transpose –“Flip” (M by N becomes N by M)
6
Operations on Matrices n Multiplication –Only possible to multiply of dimensions n x 1 by y 1 and x 2 by y 2 iff y 1 = x 2 –resulting matrix is x 1 by y 2 n e.g. Matrix A is 2 by 3 and Matrix by 3 by 4 –resulting matrix is 2 by 4 n Just because A x B is possible doesn’t mean B x A is possible!
7
Matrix Multiplication Order n A is n by k, B is k by m n C = A x B defined by n BxA not necessarily equal to AxB
8
Example Multiplications
9
Inverse n If A x B = I and B x A = I then A = B -1 and B = A -1
10
3D Transforms n In 3-space vectors are transformed by 3 by 3 matrices
11
Scale n Scale uses a diagonal matrix n Scale by 2 along x and -2 along z
12
Rotation n Rotation about z axis n Note z values remain the same whilst x and y change Y X
13
Rotation X, Y and Scale n About X n About Y n Scale (should look familiar)
14
Homogenous Points n Add 1D, but constrain that to be equal to 1 (x,y,z,1) n Homogeneity means that any point in 3-space can be represented by an infinite variety of homogenous 4D points –(2 3 4 1) = (4 6 8 2) = (3 4.5 6 1.5) n Why? –4D allows as to include 3D translation in matrix form
15
Homogenous Vectors n Vectors != Points n Remember points can not be added n If A and B are points A-B is a vector n Vectors have form (x y z 0) n Addition makes sense
16
Translation in Homogenous Form n Note that the homogenous component is preserved (* * * 1), and aside from the translation the matrix is I
17
Putting it Together n R is rotation and scale components n T is translation component
18
Order Matters n Composition order of transforms matters –Remember that basic vectors change so “direction” of translations changed
19
Overview n More Maths –Rotations and translations –Homogenous co-ordinates n General Camera –Specification –Mapping to world coordinates
20
Simple Camera (Cross Section) Z-Z Y d COP y max y min
21
General Camera n View Reference Point (VRP) –where the camera is n View Plane Normal (VPN) –where the camera points n View Up Vector (VUV) –which way is up to the camera n X (or U-axis) forms LH system
22
UVN Co-ordindates n View Reference Point (VRP) –origin of VC system n View Plane Normal (VPN) –Z (or N-axis) of VC system n View Up Vector (VUV) –determines Y (or V-axis) of VCS n X (or U-axis) forms LH system
23
World Coords and Viewing Coords Y X Z V U N VUV VRP We want to find a general transform (EQ1) of the above form that will map WC to VC
24
View from the Camera VUV N and VPN into the page U V XY Z xmin, ymin xmax, ymax
25
Finding the basis vectors n Step 1 - find n n Step 2 - find u n Step 3 - find v
26
Finding the Mapping (1) n u,v,n must rotate under R to i,j,k of viewing space n Both basis are normalised so this is a pure rotation matrix –recall in this case R T = R -1
27
Finding the Mapping (2) n In uvn system VRP (q) is (0 0 0 1) n And we know from EQ1 so
28
Complete Mapping n Complete matrix
29
For you to check n If n Then
30
Using this for Ray-Casting n Use a similar camera configuration (COP is usually, but not always on -n) n To trace object must either –transform spheres into VC –transform rays into WC
31
Ray-casting n Transforming rays into WC –Transform end-point once –Find direction vectors through COP as before –Transform vector by –Intersect spheres in WC
32
Ray-casting n Transforming spheres into VC –Centre of sphere is a point so can be transformed as usual (WC to VC) –Radius of sphere is unchanged by rotation and translation (and spheres are spheroids if there is a non-symmetric scale)
33
Tradeoff n If more rays than spheres do the former –transform spheres into VC n For more complex scenes e.g. with polygons –transform rays into WC
34
Alternative Forms of the Camera n Simple “Look At” –Give a VRP and a target (TP) –VPN = TP-VRP –VUV = (0 1 0) (i.e. “up” in WC) n Field of View –Give horizontal and vertical FOV or one or the other and an aspect ratio –Calculate viewport and proceed as before
35
Animated Cameras n Animate VRP (observer-cam) n Animate VPN (look around) n Animate TP (track-cam) n Animate COP –along VPN - zoom –orthogonal to VPN - distort
36
Summary n We set up the mathematics of transformations between co-ordinate spaces n We created a more general camera which we can use to create views of our scenes from arbitrary positions n Formulation of mapping from WC to VC (and back)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.