Re: Breve Help

jon klein <[email protected]> Wed, 23 Feb 2005 09:23:28 -0500
Newsgroups gmane.comp.breve
Message-ID <[email protected]>
On Feb 22, 2005, at 8:59 PM, Cindy Chan wrote:

> I have been experimenting with Breve and I want to know how I can find 
> the distance between two spheres. So far, when I click one of the 
> spheres, the time interval and location is automatically printed and 
> the neighbour lines are shown. However, I want the simulation to be 
> able to print all the distances from the sphere i click..with all its 
> neighbours (basicaly give me the length of the neighbour lines). Is 
> this possible?!

You can get a list of the agent's neighbors using "get-neighbors".  The 
distance between two objects is found by subtracting the location of 
one from the other (to get the vector separating them) and then getting 
the size of that vector.

Since you want to do it when the agent is clicked on, you'll have to 
put your code in the controller object's "click" method.  This method 
is called automatically when an object is selected.  The code should 
look something like this:

+ to click on agent (object):
	neighbors (list).
	current (object).

	if !agent: return.

	foreach current in neighbors: {
		print | (self get-location) - current |.
	}

> I was also wondering if its possible to click an object, and have its 
> location printed at every time interval, example every 3 seconds for 3 
> minutes. As a result, I would be able to map out the sphere's path 
> later.

Again, using the click method, you can assign a class variable in the 
controller to the currently selected object.  Then, as part of the 
controller's iterate method, you can print out the location of the 
object.

- jon klein

_______________________________________________
breve mailing list
[email protected]
http://lists.spiderland.org/mailman/listinfo/breve