Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does vector minus vector actually mean

Trying to understand (did not take many math classes, so I apologize I know I should know this) what it means when I have some code that takes 2 vectors and subtracts one from the other to equal a new vector. I kind of get what a vector in unity is, it's like a point with 3 numbers that represent it's position in the world. But what I am confused about is when I have this for instance

Transform target = GameObject.FindWithTag ("Player").transform;
Vector3 targetDir = target.position - transform.position;

So I obviously know what subtraction means, but what I am trying to understand is what the new targetDir is since you're subtracting 2 points, not numbers. Do you simply just minus the equivalent axis (x-x, y-y, z-z) and that gives you the new vector?


2 Answers

An image speaks more than a thousand words:

enter image description here

like image 74
David Avatar answered Jul 06 '26 06:07

David


Put simply: Yes. Subtraction of vectors is equivalent to a composition of subtraction of their components, or in other words, P2 - P1 = { x2 - x1, y2 - y1, z2 - z1 }.

http://hotmath.com/hotmath_help/topics/adding-and-subtracting-vectors.html

like image 31
Shotgun Ninja Avatar answered Jul 06 '26 05:07

Shotgun Ninja



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!