user3380292
user3380292

Reputation:

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?

Upvotes: 2

Views: 7169

Answers (2)

David
David

Reputation: 16277

An image speaks more than a thousand words:

enter image description here

Upvotes: 8

Shotgun Ninja
Shotgun Ninja

Reputation: 2540

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

Upvotes: 1

Related Questions