Vectors in XNA

There are 3 main Vectors in XNA, namely, Vector2, Vector3 & Vector4. (Don't ask me what happened to Vector1. I ate it up! Stick out tongue)

The most feature rich, being Vector 4, which is a homogeneous coordinates representation, which is really makes calculation possible in projective space, just as Cartesian coordinates, do, in Eclidean space.

The main difference betwen the different Vectors in XNA is their number of representation,

  • Vector2
    • X-component
    • Y-component
  • Vector3
    • X-component
    • Y-component
    • Z-component
  • Vector4
    • X-component
    • Y-component
    • Z-component
    • W-component

Homogenous coordinates is a common fixture in computer graphics as they do a really good job with rpresenting a translation as a matrix operation. However, do not use Vector4 just because it's powerful. Although it's powerful, it does take up resources as well. Remember, in games, performance is once of the key factors!

If you're thinking of what to use to represent the direction in which an object is going to in a 3D-Game, Vector3 would be able to do the job. If you're working on just a 2D game, Vector2 would do the job. Smile

An example of Vector3 in usage is: Vector3 rotation = new Vector3(MathHelper.ToRadians(90), 0, 0);

Read the complete post at http://darrensim.com/blogs/techbits/archive/2007/04/26/vectors-in-xna.aspx

Published Thursday, April 26, 2007 4:59 PM by Technical Bits
Filed under: ,