Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 24 May 2012 06:34 PM |
This is correct, right?
math.sqrt(((Start.X-Goal.X)^2) + ((Start.Y-Goal.Y)^2))
|
|
|
| Report Abuse |
|
|
|
| 24 May 2012 06:36 PM |
| It would be Goal - Start I think. That's how it is in the actual real-life-math formula. It may work either way here. |
|
|
| Report Abuse |
|
|
|
| 24 May 2012 06:48 PM |
Why not just use the .magnitude of a Vector2?
-[::ƧѡÎḾḠΰῩ::]-[::Maker of stuff and Helper of Scripting::]- |
|
|
| Report Abuse |
|
|
PsychoBob
|
  |
| Joined: 08 Jul 2009 |
| Total Posts: 11047 |
|
|
| 24 May 2012 07:44 PM |
@dark
Because of how math works, (a-b)² = (b-a)² assuming that both a and b are real numbers (as opposed to imaginary). This is because:
-(a-b) = -a+b = b-a
But when you square a number or expression, the result is always positive or zero, unless the number is imaginary or complex with a non-zero imaginary part.
So, yes, it does go (goal - start) rather than (start - goal) as per convention, it doesn't really matter. |
|
|
| Report Abuse |
|
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 24 May 2012 07:47 PM |
b-a or a-b doesn't matter when you're squaring stuff... Just making sure it wasn't that part of code that was messing with my thing. |
|
|
| Report Abuse |
|
|
MrMcAero
|
  |
| Joined: 21 Apr 2012 |
| Total Posts: 671 |
|
| |
|