What I'm trying to find out is what impact does a Vector3 minus another vector3 equals. What does this give specifically.
what does a vector-vector give?
1 answer
Vectors are a general concept from linear algebra.
A vector space V is a set[^1] of things that we call vectors.
Vector spaces are associated with a field[^2], usually the real numbers or complex numbers. These are usually called scalars and are number-like.
[^1]: A set is an unordered collection. Sets form the basis of almost all mathematics.
[^2]: A field is a "nonzero commutative division ring", meaning it has "nice" addition, subtraction, multiplication, and division. "Nice" meaning multiplication/division distribute over addition; addition/subtraction and multiplication/division are inverses; addition is commutative and associative; and multiplication is commutative and associative.
There are two operations defined on vector spaces:
- For vectors
aandbin vector spaceV,a + bis a vector inV - For vector
vinVandca scalar,c * vis a vector inV.- in math, the
*is often / usually omitted:cvorc v. - Note: rigorous mathematics always puts the scalar on the left. Thus
v c(ifvis a vector andcis a scalar) is invalid when being rigorous -- but most implementations/mathematicians won't care
- in math, the
These operations have to satisfy these properties:
- Addition is commutative:
a + b = b + a - Addition is associative:
a + (b + c) = (a + b) + c - Scalar multiplication plays nice (compatible):
a * (b * v) = (a * b) * v = b * (a * v)and1 * v = v - Multiplication distributes, both ways:
a * (u + v) = a * u + a * vand(a + b) * u = a * u + b * v
These are two more important properties of vector spaces:
- There exists a
0element inV:0 + v = vfor allvinV- NOTE: This
0is NOT the number0. It's usually written bold to differentiate it.
- NOTE: This
- There exists an inverse for
v, called-v, such thatv + (-v) =0
This final property is what gives us u - v = u + (-v)
TL;DR: Vectors are like numbers, except you can only
- add them together
- subtract them
- make them bigger/smaller (but not multiply two together)
Okay, so what does this mean?
In practice, you don't deal with abstract objects called vectors. You deal with a specific type of object that has these properties[^3], like Vector3s in ROBLOX.
Vectors inherently describe change in value -- instead of thinking of 0 as a particular place, think of it as a description of "when I'm here... 0 is still here". In particular, me + 0 is still me.
So if someone is a bit to the right of me, say, 5 studs... They happen to be at them = me + Vector3.new(5, 0, 0). How would I have figured out where they were just given me and them? It's simple algebra!
-- NOTE: NOT LUA
-- Psuedo math/lua
them = me + Vector3.new(5, 0, 0)
-- subtract `me` from both sides:
them - me = me + Vector3.new(5, 0, 0) - me
them - me = Vector3.new(5, 0, 0) + me - me
them - me = Vector3.new(5, 0, 0)
Thus when them and me are positions, them - me is the displacement from me to them (you can think of this more easily with numbers. If me = 5 and them = 9, how do I get from me to them? I add 4 -- 9 - 5 = 4.)
For Vector3s, you just subtract the corresponding components -- this is obvious from the necessary properties of - and given that addition just adds the corresponding components.
[^3]:Ex.: prove that Vector3s satisfy all the above properties
This discussion is preserved as it was. New answers, comments, and votes are closed.
