<aside> 💡 Fore detailed mathematics check the Adventure in Math realm page.
</aside>
Character’s position is shown by a vector which in game dev is represented by a tuple containing it’s position in the cartesian plane basically in cartesian coordinate.
sin()
and cos()
are relatively expensive functions compared to just floating point addition, and when you're doing it at 60 frames per second, the differences become negligible. Plus, having each vector as its dimensional components has its advantages. But that said, there's plenty of times when we use the cos and sin representations as well.We can do distance comparison faster by not doing the square root as it’s comparison.
Scaling a vector (multiplying and dividing by a scalar) help in speeding or slowing down the character velocity as velocity is also depicted as vector.
If you have a vector, it spans a space. For just a vector, this space is a line. You can get every point in that space just using the vector, and a scalar (a number) you multiply it with.
Unit/Basis/Normalized vector is used to get the direction the player is facing to (view vector) and is used a lot.
You can use matrices with a sense of direction, without needing to spend hundreds of hours mastering linear Algebra (Specially for tech art).
In graphics, we mostly transform three dimensional vectors using 3x3 matrices. Another advantage of graphics is, we mostly deal with square matrices with linearly Independent columns, that makes it easy again to view them just in terms of their column space and not worry about the other subspaces of the matrix such as its left null space.
Backstabbing is checking if a character is behind some other character or not. This is done using dot products.
We make use of normalized vectors as they give the direction of the characters.