# How To Use Vector3 in XNA

Vector3 is a 3-components based struct which is generally used in 3d space(x,y,z).

So vector3 is much more used in loading models and 3d transformations.

As we analyze vector3' structure we will figure out that most of the structure is already being used by Vector2 so some will be the same.

We can add 2 Vector3 variable:

Returns a vector3(0,0,1):

BaryCentric Calculation:

Calculating CatmullRom:

Using Clamp:

Calculate Cross Product:

Calculate Distance:

Calculate Distance Squared:

Calculating Divide:

Calculating Dot Product of the given Vector3:

Setting Down Vector3(0,-1,0):

Setting Forward Vector3(0,0,-1):

Using Hermite to perform a spline interpolation:

Setting Left Vector3(-1,0,0):

Using Lerp for a linear interpolation:

Getting the Max Vector3:

Getting the Min Vector3:

Multiplying 2 Vector3:

Returning Negative of the given Vector3:

Creating an unit vector from the specified Vector3:

Setting One Vector3(1,1,1):

Using Reflect with a normal:

Setting Right Vector3(1,0,0):

Using SmoothStep for interpolating a cubic equation:

Subtracting 2 Vector3:

Transforming Vector3:

TransformNormal is different from the Transform function so it only transforms normal values:

Setting UnitX,UnitY,UnitZ,Up and Zero Vector3:

As I said before Vector3 are used in 3D Coordinate systems(x,y,z)

You can use it for Model Transformations(Rotate,Scale,Move).