Please note that I will first explain what each concept is, and then I will write up how to calculate/get each concept afterwards.
A scalar is simply another name for a number, however it uses that name to indicate a difference between a Vector and a single number. (Or other mathematical structures)
In the field of game programming, Vectors play a key role in almost every aspect. In its simplest form, a Vector is a collection of 2 or more scalars that indicate a point in space, relative to the Origin [3D=(0,0,0) | 2D=(0,0)]. Each scalar in a Vector is called a component, and indicates the distance along the corresponding axis from the origin. For example, the Vector (9,5) is 9 units along the X axis, and 5 units along the Y axis. Vectors can be used to indicate positions, directions, and many other things. It all depends on the context, and what the Vector is relative to. (World/Local space)
Vectors in pure maths generally refer to a direction rather than a point, however in computer graphics we use Vector structures to represent a point. We can view a point as the end of a direction from the origin, however when written, points usually are written with parenthesis (0,0) and Vectors are usually written either using angle brackets <0,0> or in component form, where each part (component) of the Vector exists as the coefficient of a unit vector pointing along the corresponding axis. [More on Unit Vectors later]
For example, the Vector <9,5> can also be written as 9x + 5y.
The accepted way of indicating something is a Vector in digital form (as opposed to written on paper) is to bold the vector, for example i.
So now that you are most likely confused, let us move on to Unit Vectors. A Unit Vector is a vector with a distance of 1. This is the way you represent an axis in Vector form. For example, the unit vector for the X axis in 3D space is <1,0,0>. You can see that in our component form, the scalar co-efficient of x is 9, which is the distance along the X axis.
Key to getting the Unit Vector, is a concept called Magnitude. This is represented by two bars on each side of the vector. The magnitude of the vector is a scalar representation of the distance from the origin, so if you need to find the distance of a Vector from the origin, you are simply calculating the Magnitude.
The magnitude is found by applying the distance equation between the Vector and the Origin. The distance between two vectors is found by taking the square root of the squares of the difference between the corresponding components. Quite a mouthful, isn’t it?
To find this in code, we use the following:
public double Distance(Vector3 i, Vector3 j)
{
double x, y, z;
x = Math.Pow((i.X - j.X), 2);
y = Math.Pow((i.Y - j.Y), 2);
z = Math.Pow((i.Z - j.Z), 2);
return result = Math.Sqrt(x + y + z);
}
In Mathematical notation, this is just:

So for magnitude, where we are getting the distance between the Vector and the origin, we are subtracting 0 from each component, which simplifies the equation down to:
![clip_image002[13] clip_image002[13]](http://www.chr0n1x.com/blog/image.axd?picture=clip_image00213_thumb.gif)
So now how do we use the result of this to find the unit vector? Well the equation for a unit vector is
. This pretty much means that we divide each component of our vector by the magnitude of the vector. This is what we do to “normalise” a vector, and this allows us to multiply the vector by a number and not change its direction.
Remember that Vectors are a way of representing many things, although the common definition is that they represent a direction combined with a magnitude, which we can use to get a point, as if we moved the point from the origin along the direction using the magnitude. It is all about context, and that determines how you use the vector and its components. For example, a normal is a vector which indicates the direction perpendicular to the object’s tangent. (A tangent is a vector parallel to the line/object)
Another calculation common in computer graphics that uses Vectors is the Dot Product. This is a multiplication of two vectors which gives a scalar value that can indicate many things, usually though it can be used to get the angle between two vectors. The dot product is rather simple, you multiply each component of a vector with the corresponding component in the 2nd vector, and then add the result of each of these multiplications together to get a scalar value.

We can use this and:

to find the angle between the two vectors. After rearranging we use

(Note that the cos is simply ArcCos)
I hope this has explained what a Vector is and some key aspects about it, if you have any further questions leave a comment. Comments and criticism welcome. I plan to write another post on Matrices, with a focus on their application in computer graphics.
If I have missed anything, just tell me in a comment and I will add it in a later post, this was written after a nice lunch on Christmas day, and I am a bit tired now.