05. vectors
Post on 18-Aug-2015
57 Views
Preview:
TRANSCRIPT
Video Game Development: Vectors A. 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
Video Game Development: Vectors A. Babadi 2 of 16
Outline
What is a game engine?
Vector definition
The dot product
Vector projection
The cross product
Video Game Development: Vectors A. 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.
Video Game Development: Vectors A. 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.
Video Game Development: Vectors A. 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.
Video Game Development: Vectors A. 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.
π = ππ₯ , ππ¦, ππ§
Video Game Development: Vectors A. 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
ππ
Video Game Development: Vectors A. 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:ππ
Video Game Development: Vectors A. Babadi 9 of 16
The Dot Product
π. π = π π cos πΌ
The dot product is related to the angle between two vectors.
Video Game Development: Vectors A. 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.
Video Game Development: Vectors A. 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 π.
Video Game Development: Vectors A. Babadi 12 of 16
cos πΌ =π₯
πβ π₯ = π cos πΌ =
π. π
π
We now have this formula for the projection of π onto π:
ππππππ =π.π
π 2π
Projecting Vectors
πΌ
π
π
π₯
Video Game Development: Vectors A. 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.
π Γ π =
π π πππ₯ ππ¦ ππ§ππ₯ ππ¦ ππ§
= ππ¦ππ§ β ππ§ππ¦, ππ§ππ₯ β ππ₯ππ§, ππ₯ππ¦ β ππ¦ππ₯
Video Game Development: Vectors A. 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.
Video Game Development: Vectors A. 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.
top related