Thedagz
|
  |
| Joined: 10 Mar 2012 |
| Total Posts: 798 |
|
|
| 10 Apr 2016 12:17 PM |
Is Distance Formula more accurate then magnitude?
Part1 = game.Workspace.Part1.Position Part2 = game.Workspace.Part2.Position
D = math.sqrt((Part2.x - Part1.x)^2+(Part2.y - Part1.y)^2+(Part2.z - Part1.z)^2) print(D) X = (Part1 - Part2).magnitude print(X)
I'm not sure if something is wrong with my math for the distance formula but I would get different numbers when printing both of them but still very similar. |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2016 12:42 PM |
math.exp?
magnitude is just cleaner i think |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2016 01:02 PM |
| It's the same thing, I'm pretty sure. magnitude is as accurate as can be. |
|
|
| Report Abuse |
|
|
crome60
|
  |
| Joined: 22 Nov 2008 |
| Total Posts: 15266 |
|
| |
|
|
| 10 Apr 2016 01:08 PM |
| both do the same thing, but magnitude is much better because it's so clean |
|
|
| Report Abuse |
|
|
|
| 10 Apr 2016 04:06 PM |
| Technically speaking, both use the distance formula. The reason you're getting different results is that Roblox calculates the magnitude internally using floats whereas in Lua it's all done using doubles (more precise). However the difference is insignificant in almost all cases when dealing with length, and you're better off using the Magnitude property. |
|
|
| Report Abuse |
|
|