Mobility models for ad-hoc networks
Nomadic model
The '+' simbol denotes the gravity center.
The "0" node is a target point, it is not animated.
Click with the mouse to move the entire grid toward this position.
public static Pos move_nomadic(int node) {
Pos p=(Pos)loc.get(new Integer(node)); // real position
Pos r=(Pos)ref.get(new Integer(node)); // theoretic position
double d=p.distance(r);
int xi=(int)(Math.random()*(d+10));
int yi=(int)(Math.random()*(d+10));
if (p.isLeft(r)) xi+=p.x; else xi=p.x-xi;
if (p.isUp(r)) yi+=p.y; else yi=p.y-yi;
return new Pos(xi,yi);
}
If you have not the correct behavior, please let your browser to totally reload the
contents of this page. The complete source code of these applets is here.
Miguel Sanchez 1998
|