15 #define ROW_SIZE (2*TABLE_SIZE+1)
17 #pragma message("ABS functions might have been removed; need to verify to make sure they weren't needed")
50 case kTank:
return 24;
54 assert(!
"Unknown motion model");
61 std::vector<deltaSpeedHeading> acts;
63 for (
unsigned int x = 0; x < acts.size(); x++)
67 neighbors.push_back(newLoc);
81 actions.push_back(sh);
107 actions.push_back(sh);
110 actions.push_back(sh);
113 actions.push_back(sh);
120 actions.push_back(sh);
134 actions.push_back(sh);
137 actions.push_back(sh);
140 actions.push_back(sh);
143 actions.push_back(sh);
146 actions.push_back(sh);
149 actions.push_back(sh);
152 actions.push_back(sh);
159 for (
int x = 0; x <= 2; x++)
164 actions.push_back(sh);
166 for (
int y = 1; y <= 3; y++)
170 actions.push_back(sh);
173 actions.push_back(sh);
181 for (
int x = -1; x <= 1; x++)
186 actions.push_back(sh);
188 for (
int y = 1; y <= 3; y++)
192 actions.push_back(sh);
195 actions.push_back(sh);
203 for (
int x = -1; x <= 1; x++)
208 actions.push_back(sh);
210 for (
int y = 1; y <= 3; y++)
214 actions.push_back(sh);
217 actions.push_back(sh);
221 else { assert(
false); }
222 if (actions.size() == 0)
227 actions.push_back(act);
233 std::vector<deltaSpeedHeading> acts;
236 for (
unsigned int x = 0; x < acts.size(); x++)
277 float xoffset[16] = {1.0, 2.0, 1.0, 1.0,
278 0.0, -1.0, -1.0, -2.0,
279 -1.0, -2.0, -1.0, -1.0,
280 0.0, 1.0, 1.0, 2.0 };
281 float yoffset[16] = {0.0, 1.0, 1.0, 2.0,
283 0.0, -1.0, -1.0, -2.0,
284 -1.0, -2.0, -1.0, -1.0};
293 else if (s.
speed < 0)
306 float xoffset[24] = {1.0, 3.0, 3.0, 1.0, 2.0, 1.0,
307 0.0, -1.0, -2.0,-1.0, -3.0,-3.0,
308 -1.0, -3.0, -3.0,-1.0, -2.0,-1.0,
309 0.0, 1.0, 2.0, 1.0, 3.0, 3.0 };
310 float yoffset[24] = {0.0, 1.0, 2.0, 1.0, 3.0, 3.0,
311 1.0, 3.0, 3.0, 1.0, 2.0, 1.0,
312 0.0, -1.0, -2.0,-1.0, -3.0,-3.0,
313 -1.0, -3.0, -3.0,-1.0, -2.0,-1.0};
322 else if (s.
speed < 0)
335 float xoffset[24] = {1.0, 3.0, 3.0, 1.0, 2.0, 1.0,
336 0.0, -1.0, -2.0,-1.0, -3.0,-3.0,
337 -1.0, -3.0, -3.0,-1.0, -2.0,-1.0,
338 0.0, 1.0, 2.0, 1.0, 3.0, 3.0 };
339 float yoffset[24] = {0.0, 1.0, 2.0, 1.0, 3.0, 3.0,
340 1.0, 3.0, 3.0, 1.0, 2.0, 1.0,
341 0.0, -1.0, -2.0,-1.0, -3.0,-3.0,
342 -1.0, -3.0, -3.0,-1.0, -2.0,-1.0};
351 else if (dir.
speed < 0)
384 float xoffset[16] = {1.0, 2.0, 1.0, 1.0,
385 0.0, -1.0, -1.0, -2.0,
386 -1.0, -2.0, -1.0, -1.0,
387 0.0, 1.0, 1.0, 2.0 };
388 float yoffset[16] = {0.0, 1.0, 1.0, 2.0,
390 0.0, -1.0, -1.0, -2.0,
391 -1.0, -2.0, -1.0, -1.0};
397 else if (s.
speed < 0)
411 float xoffset[24] = {1.0, 3.0, 3.0, 1.0, 2.0, 1.0,
412 0.0, -1.0, -2.0,-1.0, -3.0,-3.0,
413 -1.0, -3.0, -3.0,-1.0, -2.0,-1.0,
414 0.0, 1.0, 2.0, 1.0, 3.0, 3.0 };
415 float yoffset[24] = {0.0, 1.0, 2.0, 1.0, 3.0, 3.0,
416 1.0, 3.0, 3.0, 1.0, 2.0, 1.0,
417 0.0, -1.0, -2.0,-1.0, -3.0,-3.0,
418 -1.0, -3.0, -3.0,-1.0, -2.0,-1.0};
425 else if (s.
speed < 0)
440 float xoffset[24] = {1.0, 3.0, 3.0, 1.0, 2.0, 1.0,
441 0.0, -1.0, -2.0,-1.0, -3.0,-3.0,
442 -1.0, -3.0, -3.0,-1.0, -2.0,-1.0,
443 0.0, 1.0, 2.0, 1.0, 3.0, 3.0 };
444 float yoffset[24] = {0.0, 1.0, 2.0, 1.0, 3.0, 3.0,
445 1.0, 3.0, 3.0, 1.0, 2.0, 1.0,
446 0.0, -1.0, -2.0,-1.0, -3.0,-3.0,
447 -1.0, -3.0, -3.0,-1.0, -2.0,-1.0};
455 else if (dir.
speed < 0)
488 float dist = sqrt((l1.
x-l2.
x)*(l1.
x-l2.
x)+(l1.
y-l2.
y)*(l1.
y-l2.
y));
490 dist = ceil(dist/2.0);
492 dist = ceil(dist/3.0);
532 double dist[4] = {1.0, 2.24, 1.42, 2.24};
540 double dist[6] = {1.0, 3.16, 3.61, 1.42, 3.61, 3.16};
548 double dist[6] = {1.0, 3.25, 3.75, 1.50, 3.75, 3.25};
574 double dist[4] = {1.0, 2.24, 1.42, 2.24};
585 double dist[6] = {1.0, 3.16, 3.61, 1.42, 3.61, 3.16};
615 return (
node == goal);
627 return (uint64_t)((uint64_t)
node.x<<32)|((uint64_t)
node.y<<16)|((uint64_t)
node.rotation);
629 uint64_t hval = (((int)
node.x*4)<<16)|((
int)
node.y*4);
630 hval = (uint64_t)((uint64_t)hval<<32)|((uint64_t)
node.rotation<<8)|(uint64_t)(
node.speed+4);
654 GLdouble xx, yy, zz, rad;
655 map->
GetOpenGLCoord(perc*newState.
x + (1-perc)*oldState.
x, perc*newState.
y + (1-perc)*oldState.
y, xx, yy, zz, rad);
670 GLdouble yoffset = sin(
TWOPI*rot/DEG)*rad;
671 GLdouble xoffset = cos(
TWOPI*rot/DEG)*rad;
673 glBegin(GL_TRIANGLES);
674 glColor4f(r, g, b/2, t);
675 glVertex3f(xx+xoffset, yy+yoffset, zz);
676 glColor4f(r, g/2, b, t);
677 glVertex3f(xx-xoffset, yy-yoffset, zz-rad);
678 glColor4f(r, g, b/2, t);
679 glVertex3f(xx-xoffset+0.5*yoffset, yy-yoffset-0.5*xoffset, zz);
681 glColor4f(r, g/2, b, t);
682 glVertex3f(xx+xoffset, yy+yoffset, zz);
683 glColor4f(r, g, b/2, t);
684 glVertex3f(xx-xoffset, yy-yoffset, zz-rad);
685 glColor4f(r, g/2, b, t);
686 glVertex3f(xx-xoffset-0.5*yoffset, yy-yoffset+0.5*xoffset, zz);
693 GLdouble xx, yy, zz, rad;
707 glBegin(GL_TRIANGLES);
709 surfaceNormal.
x = (((-0.5*xoffset) * (-rad)) - ((+rad) - (-2*yoffset)));
710 surfaceNormal.
y = (((rad) * (-2*xoffset)) - ((0.5*yoffset) - (rad)));
711 surfaceNormal.
z = (((0.5*yoffset) * (-2*yoffset)) - ((-0.5*xoffset) - (-2*xoffset)));
713 glNormal3f(surfaceNormal.
x, surfaceNormal.
y, surfaceNormal.
z);
714 glColor4f(r, g, b/2, t);
715 glVertex3f(xx+xoffset, yy+yoffset, zz);
716 glColor4f(r, g/2, b, t);
717 glVertex3f(xx-xoffset, yy-yoffset, zz-rad);
718 glColor4f(r, g, b/2, t);
719 glVertex3f(xx-xoffset+0.5*yoffset, yy-yoffset-0.5*xoffset, zz);
721 surfaceNormal.
x = (((+0.5*xoffset) * (-rad)) - ((+rad) - (-2*yoffset)));
722 surfaceNormal.
y = (((rad) * (-2*xoffset)) - ((-0.5*yoffset) - (rad)));
723 surfaceNormal.
z = (((-0.5*yoffset) * (-2*yoffset)) - ((+0.5*xoffset) - (-2*xoffset)));
725 glNormal3f(surfaceNormal.
x, surfaceNormal.
y, surfaceNormal.
z);
726 glColor4f(r, g/2, b, t);
727 glVertex3f(xx+xoffset, yy+yoffset, zz);
728 glColor4f(r, g, b/2, t);
729 glVertex3f(xx-xoffset, yy-yoffset, zz-rad);
730 glColor4f(r, g/2, b, t);
731 glVertex3f(xx-xoffset-0.5*yoffset, yy-yoffset+0.5*xoffset, zz);
738 GLdouble xx, yy, zz, rad;
740 glColor3f(0.5f, 0.5f, 0.5);
747 GLdouble xx, yy, zz, rad;
750 GLfloat rr, gg, bb, t;
752 glColor4f(rr, gg, bb, t);
755 glVertex3f(xx, yy, zz-rad/2);
757 glVertex3f(xx, yy, zz-rad/2);
774 const int speedCnt[3] = {3, 5, 3};
775 const int speeds[3] = {0, 1, 1};
776 const int angles[3] = {16, 16, 24};
785 for (
unsigned int x = 0; x < t.
hTable.size(); x++)
788 for (
unsigned int y = 0; y < t.
hTable[x].size(); y++)
804 assert(!
"Directional2DEnvironment::BuildHTable - Illegal base state");
823 for (
unsigned int x = 0; x < t.
hTable.size(); x++)
825 for (
unsigned int y = 0; y < t.
hTable[x].size(); y++)
836 std::vector<xySpeedHeading> succ;
838 for (
unsigned int z = 0; z < succ.size(); z++)
891 int &index1,
int &index2)
const
893 const int speeds[4] = {0, 1, 1, 1};
894 const int angles[4] = {16, 16, 24, 24};
910 const int speeds[4] = {0, 1, 1, 1};
911 const int angles[4] = {16, 16, 24, 24};
924 return t.
hTable[index1][index2];
929 const int angles[4] = {16, 16, 24, 24};
930 const int angles90[4] = {4, 4, 6, 6};
940 s3.
x = floor(s3.
x) - floor(s2.
x);
941 s3.
y = floor(s3.
y) - floor(s2.
y);
943 int whichHeuristic = -1;
944 for (
unsigned int x = 0; x <
heuristics.size(); x++)
968 if (whichHeuristic == -1)
970 assert(!
"No heuristic built");
1063 for (
int x = 0; x < DEG; x++)