Vector operations

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

TOC

Definition

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:

Properties

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

i=(100),j=(010),k=(001)a=a1i+a2j+a3k

Vector length

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

a=a12+a22++an2

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


Vector operations

Vector addition

c=a+b=(a1+b2a2+b2an+bn)

Vector subtraction

c=ab=a+(b)=(a1b2a2b2anbn)

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


Vector to scalar multiplication (vector result)

c=ba(ba1ba2ban)

Dot product (scalar product)

Defined for any dimensionality

c=ab=(a1a2an)(b1b2bn)=a1b1+a2b2++anbn

properties


Cross product (vector product)

Defined only for 3D space, order dependent

c=a×b=(a2b3a3b2a3b1a1b3a1b2a2b2)

properties

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

ab=abcos(ϕ)

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

ϕ=arccos(abab)

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:

L=a+t(ab)

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


Vectors blend (unversal for no unit vectors)

Source

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;
     RelativeVec.Normalize();

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