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 » Scripters
Home Search
 

methods of calling magnitude? aaaa

Previous Thread :: Next Thread 
Vortilis is not online. Vortilis
Joined: 06 Jul 2014
Total Posts: 14163
05 Sep 2015 08:15 PM
all i see is
while true do
magnitude jazz
end
that seems so inefficient.

http://www.roblox.com/DROP-IT-item?id=145934228 http://www.roblox.com/Toms-Bait-Beans-item?id=292084570
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
05 Sep 2015 08:19 PM
If you don't need to recalculate the magnitude move it outside the loop
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
05 Sep 2015 08:19 PM
deal with it


"You're all idiots"
Report Abuse
Vortilis is not online. Vortilis
Joined: 06 Jul 2014
Total Posts: 14163
05 Sep 2015 08:22 PM
well i suppose if while true do has an if then its ok but like wouldn't that cause some sort of lag? if i add a while wait() do then it's going to delay

http://www.roblox.com/DROP-IT-item?id=145934228 http://www.roblox.com/Toms-Bait-Beans-item?id=292084570
Report Abuse
Vortilis is not online. Vortilis
Joined: 06 Jul 2014
Total Posts: 14163
05 Sep 2015 10:00 PM
chicken nuggets
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
05 Sep 2015 10:07 PM
((x*x + y*y + z*z) ^ 0.5)

x*x is more efficient than x^2
x ^ 0.5 is more efficient than math.sqrt(x)
this doesn't make a function call
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
05 Sep 2015 11:13 PM
Just use the square of the magnitude if you are comparing it with something.

So instead of:
if (x*x + y*y + z*z)^.5 <= blah

Do
if (x*x + y*y + z*z) <= blah^2
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
05 Sep 2015 11:17 PM
VIOLATION OF RULE #1
x*x is more efficient than x^2

SENTENCE:
1000 YEARS HARD LABOR

if (x*x + y*y + z*z) <= blah*blah
only 1000 since this makes very little difference
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
05 Sep 2015 11:20 PM
lord, silly, if blah is a constant then it'll be optimized at compile-time
(3^2) vs (3*3) makes no difference, but (x^2) and (x*x) does
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
05 Sep 2015 11:22 PM
I was assuming blah wasn't a literal since it's not in your pseudo code but I guess it probably will be
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
05 Sep 2015 11:25 PM
well yeah, most of the time it's used like this it usually is a literal, but totally my fault for failing to mention it
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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