Computer Science Canada Math.Distance???????? 
Author:  xmen [ Fri Mar 26, 2004 4:35 pm ] 
Post subject:  Math.Distance???????? 
wut is it?? cuz when i tried out some programs from this forum it gaves me this error "'Distance' is not in the export of 'Math'" so wuts the problem?? or is there other syntax that can represent Math.Distance?? p.s.: my program is about balls bouncing with ball collisions 
Author:  Tony [ Fri Mar 26, 2004 4:37 pm ] 
Post subject:  
Math.Distance returns the distance between two points on a 2D plane. you need turing v4.0.5 to use it. Link is up on MX page 
Author:  recneps [ Fri Mar 26, 2004 7:34 pm ]  
Post subject:  
or just use the distance formula (where x1,y1 is point 1 and x2,y2 is point2)
**2 is same as squared and **0.5 is same as sqrt 
Author:  Cervantes [ Sat Mar 27, 2004 10:39 am ]  
Post subject:  
easiest thing to do is insert this snipit of code into your program (preferably near the top: before any time you want to use Math.Distance)
now whenever you want to use Math.Distance, you can. just take out the "." eg.

Author:  Tony [ Sat Mar 27, 2004 1:34 pm ] 
Post subject:  
aggrr... I think you're all missing the point that Distance is a function of the new Math module found in turing v4.0.5 and btw  if you're writing your own function, use (x2x1)*(x2x1) instead of **2. It is faster that way 
Author:  Cervantes [ Sat Mar 27, 2004 2:34 pm ] 
Post subject:  
oh i understand that perfectly. I was just providing another option if he doesn't want to download 4.0.5. and just a question. how is multiplying it by itself faster than squaring it? if you square it does the prog have to go back a bit to remember what its squareing or something?? 
Author:  Tony [ Sat Mar 27, 2004 3:16 pm ] 
Post subject:  
it's just the way ** operator works. It's not simple multiplication to account for decimal places, so the function ends up taking longer to execute then a simple multiplication. If you want, set up a test case for each, time it and see how much faster one is over the other 
Author:  sport [ Sat Mar 27, 2004 6:59 pm ] 
Post subject:  
a squared=a*a 
: 