Alice Community  

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

Thread Tools Display Modes
isCloseTo vs. distanceTo
Junior Member
dyanek's Avatar
Status: Offline
Posts: 10
Join Date: Feb 2008
Location: Chicago, IL
Default isCloseTo vs. distanceTo - 01-07-2011, 02:25 PM

Is there a difference between isCloseTo and distanceTo in terms of behind-the-scenes implementation? Of course, they return different values: boolean and number, respectively. But, is there a difference between how they complete\compute these tasks?

I recently found this Alice Method documentation:

This document describes these functions thusly:
isCloseTo: Returns true if within threshold metres of target object.
distanceTo: Returns the distance between the centre of the invoking object and the target object.

In other words, would the following conditionals evaluate the same?


if(car1.distanceTo(car2) < minDistance)

Reply With Quote
Senior Member
arty-fishL's Avatar
Status: Offline
Posts: 1,878
Join Date: Mar 2008
Location: In the corner of your eye
Default 01-07-2011, 06:14 PM

i dont think there is


I have mostly moved on from Alice, but may still respond to messages if important [¬º-°]¬
Reply With Quote
Posts: n/a
Default 01-10-2011, 03:46 AM

There might be no difference, but you should test them. I believe there is a small difference: obj1.distanceTo(obj2) is the distance between the CENTER of object 1 to the CENTER of object 2. I am not sure of the isCloseTo measurments, but I think it will be the distance between the EDGES of the objects' BOUNDING BOXES.
If this is correct, it is a small difference, but different nonetheless.
Reply With Quote

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 ©2022, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.