[Freeciv-Dev] (PR#6721) A Quincuncial topology
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
as info my 14.1 working code (seteable at compile time ! )
void map_distance_vector(int *dx, int *dy, int x0, int y0, int x1, int y1)
{
int Dx,Dy,D_,D__;
nearest_real_pos(&x0,&y0);
nearest_real_pos(&x1,&y1);
CHECK_MAP_POS(x0, y0);
CHECK_MAP_POS(x1, y1);
if(MB_FLAT)
{
*dx = x1 - x0;
*dy = y1 - y0;
}
else if( MB_CYLINDRICAL)
{
*dx = x1 - x0;
while (*dx > map.xsize / 2) *dx -= map.xsize;
while (*dx <= -map.xsize / 2) *dx += map.xsize;
*dy = y1 - y0;
} else if(MB_TORUS)
{
*dx = x1 - x0;
while (*dx > map.xsize / 2) *dx -= map.xsize;
while (*dx <= -map.xsize / 2) *dx += map.xsize;
*dy = y1 - y0;
while (*dy > map.ysize / 2) *dy -= map.ysize;
while (*dy <= -map.ysize / 2) *dy += map.ysize;
}
else /* if (MB_QUINCUNCIAL) TODO QUINCUNCIAL_SQ */
{
/* periodicity in x, as cylindical */
*dx = x1 - x0;
while (*dx > map.xsize / 2) *dx -= map.xsize;
while (*dx <= -map.xsize / 2) *dx += map.xsize;
*dy = y1 - y0;
D_=MAX(abs(*dx),abs(*dy));
// first central symetry
Dy=(-1-y1) - y0;
Dx=(map.xsize-x1-1) - x0;
while (Dx > map.xsize / 2) Dx -= map.xsize;
while (Dx <= -map.xsize / 2) Dx += map.xsize;
D__=MAX(abs(Dx),abs(Dy));
// get the best way
if(D__<D_)
{
D_=D__;
*dx=Dx;
*dy=Dy;
}
// second central symetry
Dy=(2*map.ysize-y1-1) - y0;
Dx=(map.xsize-x1-1) - x0;
while (Dx > map.xsize / 2) Dx -= map.xsize;
while (Dx <= -map.xsize / 2) Dx += map.xsize;
D__=MAX(abs(Dx),abs(Dy));
// get the best way
if(D__<D_)
{
*dx=Dx;
*dy=Dy;
}
}
}
Marcelo
- [Freeciv-Dev] (PR#6721) A Quincuncial topology, rt, 2003/11/06
- [Freeciv-Dev] (PR#6721) A Quincuncial topology, Guest, 2003/11/06
- [Freeciv-Dev] (PR#6721) A Quincuncial topology, Guest, 2003/11/06
- [Freeciv-Dev] (PR#6721) A Quincuncial topology,
Guest <=
- [Freeciv-Dev] (PR#6721) A Quincuncial topology, Jason Short, 2003/11/11
- [Freeciv-Dev] (PR#6721) A Quincuncial topology, Marcelo Burda, 2003/11/11
- [Freeciv-Dev] (PR#6721) A Quincuncial topology, Marcelo Burda, 2003/11/11
- [Freeciv-Dev] (PR#6721) A Quincuncial topology, Marcelo Burda, 2003/11/14
- [Freeciv-Dev] (PR#6721) A Quincuncial topology, Marcelo Burda, 2003/11/14
- [Freeciv-Dev] (PR#6721) A Quincuncial topology, Marcelo Burda, 2003/11/21
|
|