In this course concepts and requirements of the video game development will be taught. Students will get familiar to the fundamentals of the game industry and finally put all the learned stuff together to work on a small game project.
1. Video Game Development: VectorsA. Babadi 1 of 16
In The Name Of God
Video Game Development
Amin Babadi
Department of Electrical and Computer Engineering
Isfahan University of Technology
Spring 2015
Vectors
2. Video Game Development: VectorsA. Babadi 2 of 16
Outline
What is a game engine?
Vector definition
The dot product
Vector projection
The cross product
3. Video Game Development: VectorsA. Babadi 3 of 16
Game Engine
A game engine is a software designed for the creation and
development of video games.
The core functionality typically provided by a game engine
includes:
o A rendering engine,
o A physics engine,
o Scripting support,
o Multi-threading support,
o Animation support,
o Etc.
More about game engines comes in next lectures.
4. Video Game Development: VectorsA. Babadi 4 of 16
Game Engine
Examples of well-known game engines:
o CryEngine,
o Unreal Engine,
o Gamebyro,
o Unity,
o Wintermute Engine,
o XNA Game Studio,
o Game Maker.
5. Video Game Development: VectorsA. Babadi 5 of 16
Vectors
Vectors are of fundamental importance in any game engine.
They mainly are used for representing points in space and
spatial directions.
o But for now, we make no distinction between vectors representing
points and vectors representing directions, nor do we concern
ourselves with how vectors are transformed from one coordinate
system to another.
6. Video Game Development: VectorsA. Babadi 6 of 16
Vector Properties
We usually restrict ourselves to vectors defined by n-tuples of
real numbers, where n is typically 2, 3, or 4.
𝑉 = 𝑣1, 𝑣2, … , 𝑣 𝑛
The numbers 𝑣𝑖 are called the components of the vector 𝑉.
𝑉 may also be represented by a 𝑛 × 1 matrix:
𝑉 =
𝑣1
𝑣2
:
𝑣 𝑛
= 𝑣1 𝑣2 … 𝑣 𝑛
𝑇
The components can usually be labeled with the name of the
axis to which they correspond.
𝑃 = 𝑝 𝑥, 𝑝 𝑦, 𝑝 𝑧
7. Video Game Development: VectorsA. Babadi 7 of 16
Vector Properties
𝛼𝑉 = 𝑉𝛼 = 𝛼𝑣1, 𝛼𝑣2, … , 𝛼𝑣 𝑛
𝑃 + 𝑄 = 𝑝1 + 𝑞1, 𝑝2 + 𝑞2, … , 𝑝 𝑛 + 𝑞 𝑛
𝑉 = 𝑣𝑖
2
𝑛
𝑖=1
If 𝑉 = 1, 𝑉 is called a unit vector. If 𝑉 > 0, 𝑉 can be
converted to a unit vector. This operation is called
normalization.
𝑉′ =
1
𝑉
𝑉
8. Video Game Development: VectorsA. Babadi 8 of 16
The Dot Product
The dot product of two vectors supplies a measure of the
similarity (or difference) between the directions in which the
two vectors point.
𝑃. 𝑄 = 𝑄. 𝑃 = 𝑝𝑖 𝑞𝑖
𝑛
𝑖=1
It is also known as the scalar product or inner product, and is
one of the most heavily used operations in 3D graphics.
𝑃. 𝑄 may also be expressed as the matrix product:
𝑃 𝑇 𝑄 = 𝑝1 𝑝2 … 𝑝 𝑛
𝑞1
𝑞2
:
𝑞 𝑛
9. Video Game Development: VectorsA. Babadi 9 of 16
The Dot Product
𝑃. 𝑄 = 𝑃 𝑄 cos 𝛼
The dot product is related to the angle
between two vectors.
10. Video Game Development: VectorsA. Babadi 10 of 16
The Dot Product
The sign of the dot product tells us whether two vectors lie on the
same side or on opposite sides of a plane.
11. Video Game Development: VectorsA. Babadi 11 of 16
The Dot Product
Vectors whose dot product yields zero are called orthogonal
(or perpendicular) vectors.
We define the zero vector 𝟎 = 0,0, … , 0 to be orthogonal to
every vector 𝑃.
12. Video Game Development: VectorsA. Babadi 12 of 16
cos 𝛼 =
𝑥
𝑃
⇒ 𝑥 = 𝑃 cos 𝛼 =
𝑃. 𝑄
𝑄
We now have this formula for the projection of 𝑃 onto 𝑄:
𝑝𝑟𝑜𝑗 𝑄
𝑃
=
𝑃. 𝑄
𝑄 2
𝑄
Projecting Vectors
𝛼
𝑃
𝑄
𝑥
13. Video Game Development: VectorsA. Babadi 13 of 16
The Cross Product
The cross product (vector product) of two 3D vectors, returns
a new vector that is perpendicular to both of the vectors
being multiplied together.
𝑃 × 𝑄 =
𝑖 𝑗 𝑘
𝑝 𝑥 𝑝 𝑦 𝑝 𝑧
𝑞 𝑥 𝑞 𝑦 𝑞 𝑧
= 𝑝 𝑦 𝑞 𝑧 − 𝑝 𝑧 𝑞 𝑦, 𝑝 𝑧 𝑞 𝑥 − 𝑝 𝑥 𝑞 𝑧, 𝑝 𝑥 𝑞 𝑦 − 𝑝 𝑦 𝑞 𝑥
14. Video Game Development: VectorsA. Babadi 14 of 16
The Cross Product
Theorem:
𝑃 × 𝑄 . 𝑃 = 𝑃 × 𝑄 . 𝑄 = 0
The right hand rule provides an easy way for determining in which
direction the cross product points.
15. Video Game Development: VectorsA. Babadi 15 of 16
The Cross Product
Theorem:
𝑃 × 𝑄 = 𝑃 𝑄 sin 𝛼
The right hand rule provides an easy way for determining in which
direction the cross product points.
16. Video Game Development: VectorsA. Babadi 16 of 16
References
Lengyel’s textbook,
Wikipedia, and
Some other sources on the Internet.