Welcome to Darren Sim's Playpans Sign in | Join | Help

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);

Published Thursday, April 26, 2007 3:59 AM by darren.sim
Filed under: , ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Vectors in XNA

Thursday, April 26, 2007 6:06 PM by Justin Lee

Sorry, but the Vector4 is not only used in Euclidean space, but in Affine Spaces. Affine Spaces specify the set of vectors and set of points in a space. Euclidean space has an additional distance defined in the elements.

The differences between vectors and affine spaces are points. Vectors have no notion of points in spaces.

The differences between affine and euclidean spaces are distances. Affine has no notion of distances in spaces.

Then there's Cartesian space which everyone is familiar with, which is a Euclidean space defined by a orthonomal frame.

# re: Vectors in XNA

Thursday, April 26, 2007 9:54 PM by darren.sim

very interesting. Many thanks Justin for the input. Greatly appreciated. :)

Leave a Comment

(required) 
required 
(required)