Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
computing distance
Old
sidny4
Guest
 
Status:
Posts: n/a
Question computing distance - 10-21-2006, 10:57 AM

I have to compute the distance between two points entered by the user. I have already made the 4 points (x1, x2, y1, y2) and have them set to whatever the user enters. Now I just need to compute the distance which should be (x1-x2)^2 + (y1-y2)^2. Any ideas as to how to do this?
   
Reply With Quote
Old
Clunk
Guest
 
Status:
Posts: n/a
Default 10-21-2006, 04:57 PM

go to world functions and scroll down to advanced math
you should be able to use those

use Print for your answer

with a test world i created, it seems that it always truncates so the answer wont be accurate unless someone comes here and can fix that :P

Last edited by Clunk; 10-21-2006 at 05:07 PM.
   
Reply With Quote
I can't repeat your problem, could you post the code?
Old
DrJim
Guest
 
Status:
Posts: n/a
Question I can't repeat your problem, could you post the code? - 10-22-2006, 07:05 PM

Can you post the code (or the world) that's giving you the truncation problem? I've done a half dozen tests and haven't seen any real truncation issue (Alice will drop trailing zero's but that won't affect accuracy). Usually I see the opposite problem, Alice will print all twenty digits or so of a double precision number (the basic Alice format) when really only the first two or three digits are significant, but the very last digit after the decimal place is a one or two.
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.