generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Distance Formula

Previous Thread :: Next Thread 
Quenty is not online. 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
darkkiller5555 is not online. darkkiller5555
Joined: 22 Nov 2009
Total Posts: 6359
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
swimguy777 is not online. swimguy777
Joined: 30 May 2009
Total Posts: 17092
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 is not online. 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 is not online. 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 is not online. MrMcAero
Joined: 21 Apr 2012
Total Posts: 671
24 May 2012 07:52 PM
Yes.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image