Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Why do we subtract things when dealing with magnitude?

Asked by 4 years ago

Why do we subtract the position of PartA from PartB in every instance of using magnitude?

print((workspace.PartA.Position - workspace.PartB.Position).magnitude)

1
Magnitude in physics defines the length of a Vector, if we wish to calculate the distance between two points, we need to get a normal. This normal is the subtraction of the two Vectors; leaving us with the difference between each Vector point. That difference's magnitude defines the space between v1 and v2. Ziffixture 6913 — 4y
1
Think of it as how we define the space between two integers. If we wish to get the distance, we subtract each number. 18 - 15 = 3, therefore our distance is 3. However, Vector's a three-dimensional so this number isn't directly waiting for us. It's sitting in the calculated magnitude though, this is why we get the magnitude of the calculated result. Ziffixture 6913 — 4y
0
subtracting magnitudes gets one point to another, if A's mag is 5 and B's mag is 3 then out distance is 2 as Feahren said. greatneil80 2647 — 4y

2 answers

Log in to vote
2
Answered by
TrippyV 314 Donator Moderation Voter
4 years ago

It has to do a little bit with how physics works and basic vector addition/subtraction. The way that the character's position works is that it's tracked by a vector's magnitude from (0,0,0) and updated from there.

With this, subtracting someone's position from another position doesn't exactly return a distance, it returns another vector. The "magnitude" is simply the length of this vector, as a vector is defined by having both a magnitude and direction.

Ad
Log in to vote
0
Answered by 4 years ago

By subtracting the the position of PartB from PartA, you are getting a vector3 value which is the difference between the two values. For example, if you have a part at 100, 200, 100 and another at -50, -100, -50, the difference between the two positions would be 150, 300, 150. After you get the difference, you use .magnitude to basically get the length of a straight line from the position 0,0,0 to the difference between the positions of the two parts. Sorry if this explanation is a bit hard to understand.

Answer this question