PDA

View Full Version : Using the spatial relation functions


yossiy
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

chickentree
04-02-2013, 01:53 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

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

chickentree
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.