/**
* PeopleMoving
* Author: suhad
* Description:
*/
model PeopleMoving
/* Insert your model definition here */
global {
file Voronoi<-file('../includes/VoronoiVoronoi.shp');
file Peoplefile4<-file('../includes/41821.csv');
geometry shape<- envelope(Voronoi);
float pos_x;
float pos_y;
int dens;
// point location;
init {
create Polygon from: Voronoi number:190;
create Tower from: Voronoi header:true
with:[pos_x::float(read('pos_x')),pos_y::float(read('pos_y'))];
location<-point([pos_x, pos_y]);
create People from: Peoplefile4
with:[dens::int(read('count')),pos_x::float(read('pos_x')),pos_y::float(read('pos_y'))
];
location<-point([pos_x, pos_y]);
}
entities {
species Polygon
{ aspect base {draw shape color: rgb([255,255,255]) ;} }
species Tower
{float pos_x; float pos_y; int heading;
aspect Towericon {draw rectangle(1,800) color:rgb("red")
at:{location.x,location.y};
} // location size:15 rotate:90;
}
species People
{int dens;
float pos_x;
float pos_y;
aspect basepeople {draw circle(dens) color:rgb("green") at:{location.x+rnd(300),location.y+rnd(300)}
;}
//draw shape (or circle() or whatever) at:{location.x+rnd(100),location.y+rnd(100)}
}
}
}
experiment City type: gui {
output { display disp
{
species Polygon aspect: base transparency: 0.9;
species Tower aspect: Towericon ;
species People aspect: basepeople;
}
}
}
I want to give people a distance and direction according to the following equations:
Distance = [X(n)-X (n-1)]*[X(n)-X(n-1)] + [Y(n)-Y(n-1)]*[Y(n)-Y(n-1)]
Direction = arctan ((X(n)-X(n-1)) / (Y(n)-Y(n-1)))
but my problem is the embeding these aquation in the species data structure of species people ; means need to deal with pos_x, pos_y as matrix data with cell locations (i,j).
any advice please !
cheers
suhad