Use in game engines
godot vectors
Perspectives
Vectors can be broadly thought of from 3 distinct perspectives. The physics, mathematics, and computer science perspectives.
Physics perspective
Vectors are arrows pointing in space and are defined by their length and direction. As long as those two facts are the same you can move it around and it's still the same vector. Vectors are generally thought of in 3 dimensional space or on a 2 dimensional plane.
This perspetive fundamentally thinks of vectors as arrows in space which happen to have a nice numeric representation.
Computer science perspective
A vector is an ordered list of numbers. A 2 dimensional vector is an ordered list with two elements, a 3 dimensional vector has 3 elements and so on.
This perspective fundamentally thinks of vectors as lists of numbers which happen to have a nice geometric interpretation.
Mathematician perspective
A more abstract view which a vector can be anything in which there's a notion of adding together two vectors and multiplying a vector by a number called a scalar.
Two fundamental operations
Vector Addition
Adding vectors can be thought of as moving the tip of the second vector so that
it's tail sits on the tip of the first one. Then, if you draw a new vector from
the origin (or tip of the first vector) to where the tip of the second vector
now sits, that new vector is their sum.
Numerically speaking the vectors [1, 2] + [3, -1] = [1+3, 2+(-1)] = [4, 1]
Scalar Multiplication
A vector multiplied by 2 is twice as long and a vector multiplied by 1/3 is only a third of it's original length. Multiplying it by a negative number has it pointing in the opposite direction. This process is known as "scaling" and the number doing the scaling are called "scalers".
2 * [x, y] = [2x, 2y]
Vectors vs Points
People commonly talk about vectors as "points". Usually this is when dealing with a large collection of vectors. When talking about a single vector it's better to imagine it as a line from the origin.
Scalars
When you have a pair of numbers meant to describe a vector, like [3, -2], think of each one stretches of squishes the vector.
Basis Vectors
In the xy-coordinate system, there are two special vectors. The one on the x axis, pointing rightward with length 1, is commonly called "i hat" î. The other one pointing straight up with length 1 is called "j hat" ĵ.
These "basis vectors", î and ĵ are what those scalars actually scale.
Change of basis
A new pair of base vectors, different from î and ĵ can be used in what's called a "change of basis".
Linear Combinations
Any time you're scaling two vectors (by a constant like î or ĵ) and adding them like this, it's called a "linear combination" of those two vectors.
Normally, unless the two vectors are pointing the same direction or are at the origin, you can reach all points in space with these linear combinations.
Span
The set of all possible vectors you can reach with linear combinations of a given pair of vectors is called the "span" of those two vectors.
The span of most 2D vectors is ALL vectors, but when they line up in the same direction their span is just that certain line.
The span of two vectors is basically a way of asking what are all the possible vectors you can reach using these two by only using those fundamental operations of vector addition and scalar multiplication.
3D Span
In 3D span gets more interesting. When we have just two vectors in 3d space their span forms a plane cutting throught the origin. No matter how you scale these two vectors they can only form a plane, or if they are aligned they form a single line in space.
It gets more interesting when we add a third vector in 3D space. If your third vector happens to be sitting on the span of the first two, then the span doesn't change, you're sort of trapped on that same flat sheet. But in all other cases you can now reach all of 3D space with these 3 vectors.
Linearly Dependent vs Independent
When you have multiple vectors, and you could remove one without reducing their span, the relevant terminology is to say they are "linearly dependent".
Linear Transformations
Grid lines remain parallel and evenly spaced without changing the origin.