PGD Home

Vector Mathematics (and Matrix Operations)

by on Nov.14, 2013, under On Game Development

I have noticed that with several of my most recent projects I have had to deal with vector mathematics and matrix operations quite a lot. I used this form of mathematics in college, but it was never my strongest  point.

However, after working on the Icarus Rocket Simulator, and on Artillery! I have developed what I feel is quite a good working knowledge of this kind of mathematics. This is part of the reason why I chose to work on these projects, I wanted to improve my skills in these areas. This form of mathematics is vital in computer games, particularly 3D computer games, and it is found in everything from physics, to rendering, to Artificial Intelligence, to weapons. It is impossible to scrape by without it.

Vectors are used, amongst other things, to determine the facing or rotation of an object. For example, if an ai player is to be programmed to turn in the direction of a player or a target, this is achieved by using the currect direction vector of the Ai Player and the position of the target. Vectors can also be used to do very interesting things with objects, such as simulate gravitational forces (simply apply a vector with magnitude 9.81 on the negative Z axis) or wind  (basically the same thing, but apply the force to other axes). They can also be used to change the direction of projectiles in flight, creating curved projectiles, something I did for my Artillery game.

I have mostly used matrices for carrying out rotations and in rendering code. One of the models I used had a “muzzlepoint” node. This node was used to determine the direction that the muzzle of a gun was pointing. I accidentally rotated it by 90 degrees in my modelling tool, meaning the projectiles were being fired 90 degrees to one side. I could have simply rotated the muzzle point in the modelling tool and re-exported, but to test my skills I instead rotated it by using a matrix, and it worked perfectly!

This is the 90 degree rotation matrix:

 

R(90)  =   delim{[}{matrix{2}{2}{0  -1 1 0}}{]}        

This again, is a basic but very important skill.

I have a lot of ideas as to how I might use vectors and matrices in future, they are very useful tools, and now that I have a good commad of them I should be able to make some pretty cool things!

 

Facebooktwitterredditpinterestlinkedinmail

Leave a Reply

*

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!