Hi everyone.
I'm running simulation in an area of 1200m*1200m.
I use the following code to get the position of the node a and c:

MobileNode *a, *c;

a = (MobileNode *)(Node::get_node_by_address(index));
c = (MobileNode *)(Node::get_node_by_address(next));

a->update_position();
xa = a->X();
ya = a->Y();

c->update_position();
xc = c->X();
yc = c->Y();

//Then I calculate the distance between node a and c
AC = sqrt((xa-xc)*(xa-xc)+(ya-yc)*(ya-yc));

I think there is no problem with the above codes, but when i print out the
position of a,c and the distance AC, they are as follows:

ax=212254207 ay=1083267180 cx=-814812632 cy=1083132008
AC=-1073577898

This is obviously not correct, but I do not know where is the problem.
Does anyone has any idea on it?

Thanks in advance!

Cheers,
Zilu

Reply via email to