/**
* voronoi
* Author: skbhamidipati
* Description:
*/
model voronoi
/* Insert your model definition here */
global{
list<geometry> var0 <- voronoi([{10,10},{50,50},{90,90},{10,90},{90,10}]);
string dot_is_inside_which_polygon <-('');
point point_location;
reflex change_location{
point_location<-{rnd(100),rnd(100)};
}
init{
create polygons from: var0;
create dots number:1{
set location <- point_location;
}
loop p over:polygons{
if (length(dots inside(p))!=0){
dot_is_inside_which_polygon<-p.name;
write dot_is_inside_which_polygon;
}
}
}
}
species dots{
string holding_polygon;
reflex where_is_the_dot{
holding_polygon <- string(polygons overlapping(self));
write holding_polygon;
}
aspect d{
draw circle(1) color:#blue;
draw string(location.x with_precision 2)+","+string( location.y with_precision 2) +" @ "+string(dot_is_inside_which_polygon) size:3 color:#blue;
}
}
species polygons{
reflex a when:cycle=1{
write self.name;
}
aspect d {
draw shape color:rgb('white') border:#black;
draw name size:(5) color:#blue;
}
}
experiment naam type:gui{
output {
display map type:java2D{
species polygons aspect: d;
species dots aspect: d;
}
}
}
var0 <- var0 collect (each inter shape); //before creating the polygons agents, compute the intersection between the voronoi geometries and the world geometry.
create polygons from: var0;
Cheers,
Patrick
--
You received this message because you are subscribed to the Google Groups "GAMA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gama-platfor...@googlegroups.com.
To post to this group, send email to gama-p...@googlegroups.com.
Visit this group at http://groups.google.com/group/gama-platform.
For more options, visit https://groups.google.com/d/optout.
list<geometry> var0 <- voronoi([{10,10},{50,50},{90,90},{10,90},{90,10}]);
var0 <-var0 collect (each inter shape);