25 views

Uploaded by Charly Asomoza Ponce

Matrices en computacion grafica
Android

- Analisis Trial Mm 2015 (p2)
- Lecnotes Econ Analiyses
- Matrices Lesson
- Kruger, Westermann - Linear Algebra Operators for GPU Implementation of Numerical Algorithms
- Supplementary Materials Review of Matrix Operations All Pages
- ElementaryBasicsOfMatlab
- A 3 Social Network
- All LectureNotes
- wright1292763603.pdf
- Lect11 2009 Areafill Transformations
- matlabnotes-110104184012-phpapp01.pdf
- Matrices Are Sets of Numbers Which Are Put Inside Brackets in a Tabular Form
- Section 0001
- [C][2010][ISCAS][Pin-Chih.Lin][1]
- lecture notes
- RFO Syllabus 2
- module9-140304142722-phpapp01
- msccst102
- Opencv User
- JEE Mathematics Syllabus

You are on page 1of 12

Ting Yip

Math 308A

12/3/2001

Ting Yip

Math 308A

Abstract

In this paper, we discuss and explore the basic matrix operation such as translations,

rotations, scaling and we will end the discussion with parallel and perspective view.

These concepts commonly appear in video game graphics.

Introduction

The use of matrices in computer graphics is widespread. Many industries like

architecture, cartoon, automotive that were formerly done by hand drawing now are done

routinely with the aid of computer graphics. Video gaming industry, maybe the earliest

industry to rely heavily on computer graphics, is now representing rendered polygon in 3Dimensions.

In video gaming industry, matrices are major mathematic tools to construct and

manipulate a realistic animation of a polygonal figure. Examples of matrix operations

include translations, rotations, and scaling. Other matrix transformation concepts like

field of view, rendering, color transformation and projection. Understanding of matrices

is a basic necessity to program 3D video games.

Graphics

Polygon figures like these use many flat or conic surfaces to represent a realistic human soldier.

x y z

Points (x, y, z) in R3 can be identified as a homogeneous vector (x, y, z, h) , , ,1 with

h h h

4

h 0 on the plane in R . If we convert a 3D point to a 4D vector, we can represent a

transformation to this point with a 4 x 4 matrix.

Ting Yip

Math 308A

EXAMPLE

Point (2, 5, 6) in R3 a Vector (2, 5, 6, 1) or (4, 10, 12, 2) in R4

NOTE

It is possible to apply transformation to 3D points without converting them to 4D

vectors. The tradeoff is that transformation can be done with a single matrix

multiplication after the convertion of points to vectors. (More on this after

Translation.)

Transformation of Points

In general, transformation of points can be represented by this equation:

Transformed Point = Transformation Matrix Original Point

In a more explicit case, a plane spanned by two vectors can be represented by this

equation:

Transforme d Plane = Transforma tion Matrix Original Plane

a d

c f

a d

x

= Transforma tion Matrix b e

y

c f

a

x b +

c

d

e

f

a

b

c

d

y e

f

Ting Yip

Math 308A

Translation

A translation basically means adding a vector to a point, making a point transforms to a

new point. This operation can be simplified as a translation in homogeneous coordinate

(x, y, z, 1) to (x + tx , y + ty , z + tz, 1). This transformation can be computed using a single

matrix multiplication.

Translation Matrix for Homogeneous Coordinates in R4 is given by this matrix:

1

0

T (t x , t y , t z ) =

0

0

1

0

0

0 tx

0 t y

1 tz

0 1

Given any point (x, y, z) in R3 , the following will give the translated point.

1

0

0

1

0

0

0 t x x x + t x

0 t y y y + t y

=

1 tz z z + t z

0 1 1 1

For a sphere to move to a new position, we can think of this as all the points on the sphere move to the

translated sphere by adding the blue vector to each point.

Ting Yip

Math 308A

Graphics

In video game, objects like airplane that doesnt change its shape dynamically (rigid body) uses

Translation to move across the sky. All the points that make up the plane have to be translated by the

same vector or the image of the plane will appear to be stretched.

NOTE

x i

x +i

y + j = y + j

z k

z + k

If we have more than one point, we would have to apply this addition to every point.

x1

y

1

z1

x2 x1 i x1 + i x2 i x2 + i x1 + i

y 2 a y1 + j = y1 + j & y 2 + j = y 2 + j a y1 + j

z 2 z1 k z1 + k z 2 k z 2 + k z1 + k

x2 + i

y 2 + j

z 2 + k

1 0 0 i x1 x 2 x1 + i x 2 + i

0 1 0 j y y y + j y + j x1 + i x 2 + i

2

2

1

y + j y 2 + j

= 1

0 0 1 k z 1 z 2 z 1 + k z 2 + k 1

z 1 + k z 2 + k

1

0 0 0 1 1 1 1

As we can see, linear system is easier to solve with homogenenous coordinate

transformation.

Ting Yip

Math 308A

Scaling

Scaling of any dimension requires one of the diagonal values of the transformation matrix

to equal to a value other than one. This operation can be viewed as a scaling in

homogeneous coordinate (x, y, z, 1) to (sx x, sy y, sz z, 1). Values for sx, sy , sz greater than

one will enlarge the objects, values between zero and one will shrink the objects, and

negative values will rotate the object and change the size of the objects.

Scaling Matrix for Homogeneous Coordinates in R4 is given by this matrix:

s x

0

S (s x , s y , sz ) =

0

0

sy

0

0

0

0

sz

0

0

0

0

Given any point (x, y, z) in R3 , the following will give the scaled point.

s x

0

0

sy

0

0

0

0

sz

0

0 x

0 y

=

0 z

1 1

s x x

s y

y

sz z

1

If we want to scale the hexahedron proportionally, we apply the same scaling matrix to each point that

makes up the hexahedron.

Ting Yip

Math 308A

Rotations

Rotations are defined with respect to an axis. In 3 dimensions, the axis of rotation needs

to be specified.

A rotation about the x axis is represented by this matrix:

0

1

0 cos

R x ( ) =

0 sin

0

0

0

sin

cos

0

0

0

x 1

0

y

0 cos

R x ( ) =

z 0 sin

0

1

0

1 0

0

sin

cos

0

0 x

x

0 y

y cos z sin

=

0 z y sin + z cos

1 1

1

cos 0 sin 0

x cos

0

y 0

1

0

0

R y ( ) =

R y ( ) =

sin 0 cos 0

z sin

0

0

1

0

1 0

A rotation about the z axis is represented by this matrix:

cos

sin

R z ( ) =

0

sin

cos

0

0

0

0

1

0

0

x cos

y sin

0

R z ( ) =

z 0

0

1

1 0

0 sin

1

0

0 cos

0

0

sin

cos

0

0

0

0

1

0

0 x x cos + z sin

0 y

y

=

0 z x sin + z cos

1 1

1

0 x x cos y sin

0 y x sin + y cos

=

0 z

z

11

1

Ting Yip

Math 308A

This wire polygon cube is

represented by a matrix that contains

its vertex point in every column.

5

1

5

1

7

1

7

1

7

1

7

1

9

1

5

3

7

1

7

3

7

1

5

3

9

1

7

3

9

EXAMPLE

If we want to rotate this cube with respect to the x axis by

:

3

0

0

1

0 cos 3 sin 3

0 sin cos

3

3

0

0

0

5

1

5

1

7

1

7

1

7

1

7

1

9

1

5

3

7

1

7

3

7

1

5

3

9

1

7

3 =

9

5

7

7

5

7

5

7

5

1 9

3 1 7 3 1 7 3 1 9 3 3 7 3 3 7 3 3 9 3 3 9 3

2 2

2 2

2 2

2 2

2 2

2 2

2 2

2 2

9 1

+ 3 7 +1 3 7 +1 3 9 +1 3 7 +3 3 7 +3 3 9 +3 3 9 +3 3

2 2

2 2

2 2

2 2

2 2

2 2

2 2

2 2

1

1

1

1

1

1

1

1

Original Cube

Rotated Cube

Ting Yip

Math 308A

Projection Transformation

Even though we programmed objects in 3-Dimensions, we have to actually view the

objects as 2-Dimensions on our computer screens. In another word, we want to transform

points in R3 to points in R2 .

Parallel Projection

In parallel projection, we simply ignore the z-coordinate. This operation can be viewed

as a transformation in homogeneous coordinate (x, y, z, 1) to (x, y, 0, 1).

Parallel Matrix for Homogeneous Coordinates in R4 is given by this matrix:

1

0

P =

0

0

1

0

0

0

0

0

0

0

0

0

Given any point (x, y, z) in R3 , the following will give the parallel projected point.

1

0

0

1

0

0

0

0

0

0

0 x x

0 y y

=

0 z 0

1 1 1

Perspective Projection

Video game tends to use perspective projections over other projections to represent a real

world, where parallelism is not preserved. Perspective Projections is the way we see

things, i.e. bigger when the object is closer.

http://mane.mech.virginia.edu/~engr160/Graphics/Perspective.html

Ting Yip

Math 308A

Important :

1) Translate the eye to the Origin

2) Rotation until direction of eye is toward the negative z-axis

Object

Eye

z is the distance of the eye to the object

(Note: not your eyes but the eyes of the computer polygon person)

1 0 0 0

0 1 0 0

0 0 0 0

1

0 0 d 0

Given any point (x, y, z) in R3 , the following will give the parallel projected point.

z

1 0 0 0 x x x

d

0 1 0 0 y

y

y z

=

0 0 0 0 z 0 d

z

1

0 1 0

0 0

d

d 1

(Note: This matrix transformation does not give pixel coordinate on the monitor. The transformed

coordinate is with respect to the objects coordinate. We have to translate the objects coordinate to pixel

coordinate on the monitor.)

10

Ting Yip

Math 308A

Graphics

In sniping mode, the eye moves closer to the object.

Conclusion

I chose to do this project to show my curiosity in math and computer science. I had the

chance to talk about video games and math that are often overlooked as unrelated. As

shown in this project, Linear Algebra is extremely useful for video game graphics. Using

matrices to manipulate points is a common mathematical approach in video game

graphics.

11

Ting Yip

Math 308A

References

Dam, Andries. Introduction to Computer Graphics

http://www.cs.brown.edu/courses/cs123/lectures/Viewing3.pdf

Holzschuch, Nicola. Projectio ns and Perspectives

http://www.loria.fr/~holzschu/cours/HTML/ICG/Resources/Projections/index.html

Lay, David. Linear Algebra and its Applications. Second Edition.

Runwal, Rachana. Perspective Projection

http://mane.mech.virginia.edu/~engr160/Graphics/Perspective.html

12

- Analisis Trial Mm 2015 (p2)Uploaded byFarah Wahida Isa
- Lecnotes Econ AnaliysesUploaded byNazan Nur Kuşçuoğlu Öğünlü
- Matrices LessonUploaded byChevaneice Clarke
- Kruger, Westermann - Linear Algebra Operators for GPU Implementation of Numerical AlgorithmsUploaded byErnesto Varela
- Supplementary Materials Review of Matrix Operations All PagesUploaded byabathar
- ElementaryBasicsOfMatlabUploaded byOnee Yetoo Aseeme
- A 3 Social NetworkUploaded byMayisha Fabliha
- All LectureNotesUploaded bySrinivas Nemani
- wright1292763603.pdfUploaded byNoureddine Guersi
- Lect11 2009 Areafill TransformationsUploaded byheriyuli
- matlabnotes-110104184012-phpapp01.pdfUploaded byJohn Taulo
- Matrices Are Sets of Numbers Which Are Put Inside Brackets in a Tabular FormUploaded byVarun Panicker
- Section 0001Uploaded byUoR_Appl_LA
- [C][2010][ISCAS][Pin-Chih.Lin][1]Uploaded byAlbert Vu
- lecture notesUploaded byfdsfsdfsd
- RFO Syllabus 2Uploaded byBhaskar Mysore
- module9-140304142722-phpapp01Uploaded bySrinu Patnapu
- msccst102Uploaded byapi-3782519
- Opencv UserUploaded byful138
- JEE Mathematics SyllabusUploaded byVimarsh Srivastava
- FPGA Solver in MPCUploaded byMohan Roy
- Stiffness Analysis of FramesUploaded byCarolina Vaca
- Functions and Data StructuresUploaded byYulNguyen
- 6002_notes_07_L16Uploaded byMandar Patil
- 1 FoundationsUploaded byJM
- Ws2a Vec MatUploaded bykhicom
- NUMERICAL_METHODS_Chapter01Uploaded byHaiming Yang
- 3AbonusBUploaded byJAy
- EulerUploaded bymarian_louis
- Midterm 2009Uploaded byRabiah

- HTML Basico.pdfUploaded byCharly Asomoza Ponce
- Comandos Tcp IpUploaded bycacr_72
- Cuarta Forma NormalUploaded byCharly Asomoza Ponce
- Programa2.docxUploaded byCharly Asomoza Ponce
- cursobasicodeprogramacionencUploaded byTsunayoshi Godoy
- Practica1Compiladores.docxUploaded byCharly Asomoza Ponce
- Practica 1 Comp Il AdoresUploaded byCharly Asomoza Ponce
- Practica 1 Comp Il AdoresUploaded byCharly Asomoza Ponce
- Programa2 compiladoresUploaded byCharly Asomoza Ponce
- imagen_hggmUploaded byCharly Asomoza Ponce
- xs125Uploaded byJuan Miguel Jimenez Vela
- Act a 3Uploaded byJavier Garcia Gonzalez
- Act a 3Uploaded byJavier Garcia Gonzalez
- Concept Os Basic OsUploaded byCharly Asomoza Ponce
- El Secreto de Google CortoUploaded bypaquete267413
- disenobdUploaded byJeanMartin Caviedes
- Graf28Oct.pdfUploaded byCharly Asomoza Ponce

- Tool GeometryUploaded bydineshsetti
- Mathematical Methods in Engineering and ScienceUploaded bySoupramanien Kathirvelou
- Che Et Al 2012 Epe-pemcUploaded byChe Hang Seng
- 235723635 Principles of CAD CAM CAEUploaded byBob Benedict
- Introduction to MechanismsUploaded bykristeen78
- Cg Question BankUploaded byRudresh Vyas
- Computer GraphicsUploaded byvipanarora
- Development of a Wind Turbine Aerodynamics Simulation Module - A. Van GarrelUploaded byMd Tariq
- A Homogeneous Equation is Always ConsistentUploaded byandrew_4588
- Tilt Flapping ManiobrasUploaded bygarridolopez
- Pca TutorialUploaded byGregory A Perdomo P
- 478a3solUploaded byVenkataMurali Krishna
- Rigid Motion and Homogeneous TransformationsUploaded byPereira
- CAD Question Bank Oct2016Uploaded bySiddharth Rajendran
- Mech3460 Robotics 11 12Uploaded bySaied Aly Salamah
- Rotation MatricesUploaded byMekaTron
- S.Y.B.sc. (IT) Sem - III - Paper - II - Computer GraphicsUploaded byRula Shakrah
- Lecture 2: Geometric Image TransformationsUploaded byavilys65
- Vector SpacesUploaded byumer
- Flight Simulator of Light and Ultralight Aircraft EnUploaded byJesus Cortes
- Lecture05 TransformationUploaded byKumar Ramasamy
- CGMB214_topic 6_ Geometric TransformationUploaded byMuhammad Javeed
- Rr720306 Computer GraphicsUploaded byandhracolleges
- geomatric nonlinearity formulation in openseesUploaded bysami_bangash_1
- TransformerUploaded byMuhammad Mamoon
- MATHEMATICS FOR COMPUTER GAMES TECHNOLOGYUploaded byDerisma Derisma
- Chapter 3 b Homogeneous Tranf, Representation of Transfor, Inv of Trandformation,Fwd Inv Kiematics RPY EulerUploaded byCharlton S.Inao
- Linear Algebra MidtermUploaded byHeather Kane
- 5741Uploaded byYalçın Sabiha
- Halappg3dmetro.en USUploaded bytheimagingsource