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
|
  |
| 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
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 4705 |
|
|
| 05 Sep 2015 08:19 PM |
deal with it
"You're all idiots" |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 06 Jul 2014 |
| Total Posts: 14163 |
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|