Title | Linear Algebra in Computer Graphics and Games |
---|---|
Course | Computational Methods and Numerical Techniques |
Institution | University of Greenwich |
Pages | 3 |
File Size | 91.3 KB |
File Type | |
Total Downloads | 83 |
Total Views | 151 |
Download Linear Algebra in Computer Graphics and Games PDF
Linear Algebra in Computer Graphics and Games Overview
Vectors Using matrices in computer graphics Translation Scaling Rotation Range of projectiles Character controller Projection and Clipping
Why do we care about points in games? There are many ways of discretising geometries. Instead of always programming intricate details of graphics, games developers use maths to make their lives easier (e.g. fractals). But, essentially every graphic can be reduced to a series of points. Being able to manipulate the position of points in order to represent objects is therefore vital in game development. While much of this is automated these days, engines always need refinement and more abilities added to them. Vectors We will consider all points as column vectors: We need to introduce “Homogeneous coordinates” This is because as well as considering x, y, and z, we need to consider its projection. Homogeneous coordinates have an extra dimension called w, which scales the x,y, and z dimensions. This is also referred to as Quaternion. We will add w: 𝑥𝑥𝑥𝑥 essay to see this with a2D example:
Using matrices in computer graphics Matricesfor translation and perspective projection transformations can only beapplied tohomogeneous coordinates, which is why they are so common in3Dcomputergraphics. The x, y,and z valuesare said to be "correct"when w=1. 𝑥𝑥𝑥𝑥=𝑥𝑥𝑥1 Diagonal matrices A diagonal matrixes a matrix which has0everywhereapart from possibly on the main diagonal (formally���=0fori≠ j). For example: 20000000−1 Note that the diagonal elements may be anything, including zero–everything else must be zero Identity matrix A special, and very important, type of matrix is called an identity matrix. The notation��issued for the nondiagonal matrixwith1s down the main diagonal. For example,�� =100010001 You will see why these are special shortly! Translation A translation means adding a vector to a point–transforming a point to a new position. Translation A simple example: Let’s move our point235,oneunit in the x direction, two units in they direction, and three units in the z direction. What will its new position be? 13+25+3=358 Translation why do we need matrices? TingYip (2001)
Viewing and Projection Our eyes collapse 3-D world to 2-D retinal image (brain then has to reconstruct 3D) InCG, this process occurs by projection Projection has two parts: o ◦ Viewing transformations: camera position and direction o ◦ Perspective/orthographic transformation: reduces 3-D to 2-D Use homogeneous transformations Outline of procedure 1. Transform from world to camera coordinates 2. 2. Project into view volume or screen coordinates 3. 3. Clip geometry that falls outside of the view volume Homogeneous transformations 1. 2. 3. 4.
We need to map local coordinates to a Local to World Matrix Change from Local to World,to a World to Camera matrix Then apply the projection matrix on it. Remember that Coordinates (x, y,z,w) and (cx, cy,cz,cw) represent the same point
Cohen-Sutherland algorithm
1st bit Above top of screen (y >𝑥𝑥 𝑥𝑥) 2nd bit Below bottom of screen (y 𝑥𝑥𝑥𝑥) 4th bit Left of left edge of screen (x...