Vector operations

· Mathematics · Vector · Radford Mathematics - Vectors & Matrices · Khan Academy Linear Algebra ·



Vectors are quantities that are defined by two things:

A couple of examples of vectors are velocity and force.
In 2 dimensions, a Vector is described by two components:


All perpendicular vectors are orthogonal but not vice versa
A zero vector is orthogonal to anything including itself
The (non zero) vectors are collinear if one of them is scalar multiple of the other (same Vector of different length), the angle between collinear vectors is zero

ijk vector representation

as a sum of its components multiplied by the corresponding unit vectors i,k,k


Vector length

Vector length is equal to the square root of the sums of its squared coordinates


and also follows that $$\color{orange}\lVert\vec a\rVert^2=\vec a\cdot\vec a$$

Vector operations

Vector addition


Vector subtraction


The resulting vector c 's head is at the vector a 's head

Vector to scalar multiplication (vector result)


Dot product (scalar product)

Defined for any dimensionality



Cross product (vector product)

Defined only for 3D space, order dependent



cross product to calculate the area of a

S=a×b S=a×b2

The triangle's area is half of the parallelogram's area (see above)

Angle between vectors

Given that a and b are not zero


where ϕ is the angle between the a and b, then (?to check?):


this means that if the vectors are collinear the fraction is = 1 and the arccos(1) = 0 - zero angle between the vectors

A line crossing 2 points

Given 2 position vectors, and parametric tR the line L is given by:


the order is not important here, it can be =b+ or even +(ba)

Vectors blend (unversal for no unit vectors)


Vector3 Slerp(Vector3 start, Vector3 end, float percent)
     // Dot product - the cosine of the angle between 2 vectors.
     float dot = Vector3.Dot(start, end);

     // Clamp it to be in the range of Acos()
     // This may be unnecessary, but floating point
     // precision can be a fickle mistress.
     Mathf.Clamp(dot, -1.0f, 1.0f);

     // Acos(dot) returns the angle between start and end,
     // And multiplying that by percent returns the angle between
     // start and the final result.
     float theta = Mathf.Acos(dot) * percent;
     Vector3 RelativeVec = end - start * dot;

     // Orthonormal basis
     // The final result.
     return ((start*Mathf.Cos(theta)) + (RelativeVec * Mathf.Sin(theta)));