Introducing
Your new presentation assistant.
Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.
Trending searches
One of the most common applications in games for vector addition is physics integration. Any physically-based object will likely have vectors for position, velocity, and acceleration. For every frame (usually 1/60th of a second), we have to integrate these vectors -- that is, add the velocity to the position, and the acceleration to the velocity.
lets look at an example :
if we use simple(1,0)(0,1) and rotate it 49 degree we will get
matrix
[0.66 -0.75
0.75 0.66]
[cos(θ) -sin(θ)
sin(θ) cos(θ)]
void RotateShip(float degrees){
Matrix2x2 R = GetRotationMatrix(degrees);
for(int i=0; i<num_points; ++i){
rotated_point[i] = R * point[i];
}
}
Examples of 2D rotation
we can start by making a translation matrix T that moves from the origin to the ear pivot point, and a rotation matrix R that rotates around the origin. Now, to rotate around the ear pivot point, we can first move the ear pivot point to the origin with the inverse of T, written T-1. Then we just rotate around the origin using R, and then apply T to move the pivot point back to its original position. Here is an illustration of each step:
Dot Product
Matrices and Rotations
Importance of Length
Almost every game was created by using matrices.We need matrices for rotation,movement of objects in the game.So,matrices have essential role in building a game.For 2x2 matrix
Collision Detection
If we have a ship with velocity vector V(4,3)
we might also want to know how fast it is going,how much the screen should shake,
how much fuel it uses etc.To do that we need to find the length of Vector V.
|V| = sqrt(4^2+3^2) = sqrt(25) = 5
Collision detection involves determining when object penetrates another.It is clearly expensive proposition,particularly when large number of objects are involved and objects have complex shapes.
[a c
b d]
x(a,b) + y(c,d)
Vectors play an important role in collision detection by determining how far apart objects are from each other.The magnitude of vector can be found by taking square root of the sum of the squares of each of vector's components.
To add vectors together, you just add each component together separately. For example:
(0,1,4) + (3,-2,5) = (0+3, 1-2, 4+5) = (3,-1,9)
But Why do we want to add vectors together?
In games, vectors are used to store positions, directions, and velocities. Here are some 2-Dimensional examples:
Even though most people take it for granted,gaming technology is one of the most common applications of linear algebra.It is essential in almost every computer graphics technique employed;from scaling,to movement,and even color.Despite the amount of linear algebra used,most of the techniques are quite simple.
Vector Subtraction
Linear algebra is the study of vectors. If your game involves the position of an on-screen button, the direction of a camera, or the velocity of a race car, you will have to use vectors. The better you understand linear algebra, the more control you will have over the behavior of these vectors.
Subtraction very useful for getting a vector that points from one position to another.EX:
3D rotation
[cos(θ) -sin(θ) 0
sin(θ) cos(θ) 0
0 0 1]
Dot Product
cos(x) = A*B / |A|*|B|
Linear Algebra in Game Development