Alice Community  

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

Reply
 
Thread Tools Display Modes
Using the spatial relation functions
Old
yossiy
Junior Member
 
Status: Offline
Posts: 11
Join Date: Apr 2012
Location: Modiin, Israel
Default Using the spatial relation functions - 04-01-2013, 01:03 PM

Hi,
I'm trying to use the spatial relation functions and they do not work as I expected.
I'm attaching a sample world.
I expect that the function circle.Relation to print the relation between the circle and the camera, based on the spatial relation functions.
I would appreciate your advice.
Yossi
Attached Files
File Type: a2w SpatialRelations.a2w (115.4 KB, 5 views)
   
Reply With Quote
Print doesn't always print.
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default Print doesn't always print. - 04-02-2013, 01:53 PM

Quote:
Originally Posted by yossiy View Post
Hi,
I'm trying to use the spatial relation functions and they do not work as I expected.
I'm attaching a sample world.
I expect that the function circle.Relation to print the relation between the circle and the camera, based on the spatial relation functions.
I would appreciate your advice.
Yossi
Hi Yossiy,

There are a couple of things going on here, well okay so there are millions but who is counting? ☺
First there is IMHO a bug in print, it does not print all the time. In particular static text seems to be a problem. I could have sworn this use to work but it appears not to now. It also won’t print if I try to use the text functions to combine text with the output of a function i.e. print “It is to the left: “ joined with circle is to the left of camera as a string. This should take the value of circle is to the left of camera (True or False) and append it to It is to the left: thus printing “It is to the left: True” (or False). When run however I still get the “None” printing out.
This may be due to the fact that Alice is not just a programming language, it is also a movie rendering engine and so it tends to ignore things that do not show up in the scene.
One way around this is to just print the value as in: print circle is to the left of camera. Another way is to use 3d text, which is in the scene and thus will be updated.
Another “problem” is that the camera does not seem to work as expected. If you use another object in the scene it will work. The ground also has problems because, I believe, you cannot get in front, behind, to the left, or to the right of the ground (above and below work fine.)
I added a square to your movie and would like to point out one other thing in Alice. That is that in order for one object to be to the left, right, etc. of another object, it must be outside that object’s “bounding box” So for instance when the movie start the circle is neither above nor below the square and moving it a little in either direction will not change this. The circle must be above the top of the square before it is considered to be above it.
Your original movie assumed that if you were, for instance, to the left of an object, you could not be to its right, in front, or behind it. In fact none of these is necessarily true. There are points that will return true for both left and right at the same time. Although I cannot explain why this is, I have seen it happen.

I have added a parameter to your circle.Relation method because I was working with different objects and am too lazy to continually change each line. I also changed it so the circle is moving and the positions are relative to the square. There is also a “Z” key to move the circle down and “Space” bar to move it up.

Hope the epistle helps

Mark
Attached Files
File Type: a2w SpatialRelations(1).a2w (163.8 KB, 6 views)
   
Reply With Quote
easier to tell what's going on.
Old
chickentree
Super Moderator
 
Status: Offline
Posts: 250
Join Date: Dec 2012
Location: Frosno, Ca
Default easier to tell what's going on. - 04-02-2013, 02:33 PM

Here is one using 3D text to do the same thing but with labels. It also rounds the numbers to 3 places so that the text will fit on the screen.
Attached Files
File Type: a2w RelativeLocation.a2w (252.3 KB, 4 views)
   
Reply With Quote
Reply

Tags
spatial functions

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