00001 #include "Coord.h"
00002
00003
00004
00005
00006 const double Coord::UNDEFINED = 0.0;
00007
00008 double Coord::sqrTorusDist(const Coord& b, const Coord& playgroundSize) const {
00009
00010 double xDist = fabs(x - b.x);
00011 double yDist = fabs(y - b.y);
00012 double zDist = fabs(z - b.z);
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 if(xDist * 2.0 > playgroundSize.x)
00024 {
00025 xDist = playgroundSize.x - xDist;
00026 }
00027
00028 if(yDist * 2.0 > playgroundSize.y)
00029 {
00030 yDist = playgroundSize.y - yDist;
00031 }
00032 if(zDist * 2.0 > playgroundSize.z)
00033 {
00034 zDist = playgroundSize.z - zDist;
00035 }
00036 return xDist * xDist + yDist * yDist + zDist * zDist;
00037 }