11 :AbsMapEnvironment(mapAbs)
42 :AbsMapEnvironment(ame->GetMapAbstraction()->Clone(ame->GetMapAbstraction()->GetMap()->Clone()))
44 oi = ame->GetOccupancyInfo();
86 case kN: s.
y-=1;
break;
87 case kS: s.
y+=1;
break;
88 case kE: s.
x+=1;
break;
89 case kW: s.
x-=1;
break;
90 case kNW: s.
y-=1; s.
x-=1;
break;
91 case kSW: s.
y+=1; s.
x-=1;
break;
92 case kNE: s.
y-=1; s.
x+=1;
break;
93 case kSE: s.
y+=1; s.
x+=1;
break;
100 if (map->CanStep(s.
x, s.
y, old.
x, old.
y))
159 case kN: angle.
Set(0,-1);
break;
160 case kS: angle.
Set(0,1);
break;
161 case kE: angle.
Set(1,0);
break;
162 case kW: angle.
Set(-1,0);
break;
163 case kNW: angle.
Set(-1,-1);
break;
164 case kSW: angle.
Set(-1,1);
break;
165 case kNE: angle.
Set(1,-1);
break;
166 case kSE: angle.
Set(1,1);
break;
170 double newProportion = 1 - oldProp;
203 if (sqrt(x*x + y*y) > 1)
204 newAngle.Normalize();
206 newAngle.SetUpdateTime(t);
214 Vector2D storeme = oldProp * oldAngle + newProportion * angle;
222 std::vector<xyLoc> neighbours;
223 GetSuccessors(s, neighbours);
228 for (
unsigned int i=0; i<neighbours.size(); i++)
257 if (sqrt(x*x + y*y) > 1)
258 newAngle.Normalize();
259 newAngle.SetUpdateTime(t);
265 Vector2D storeme = oldProp * oldAngle + newProportion * angle;
303 if (sqrt(x*x + y*y) > 1)
304 newAngle.Normalize();
306 newAngle.SetUpdateTime(t);
312 Vector2D storeme = oldProp * oldAngle + newProportion * angle;
347 if (sqrt(x*x + y*y) > 1)
348 newAngle.Normalize();
350 newAngle.SetUpdateTime(t);
356 Vector2D storeme = oldProp * oldAngle + newProportion * angle;
389 double hCost = HCost(l1, l2);
410 double weight1 = 0;
double weight2 = 0;
418 weight1 =
diffWeight * ((1 - ((old.
x * angle.
x)+(old.
y * angle.
y)))/2);
434 weight2 =
diffWeight * ((1 - ((old.
x * angle.
x)+(old.
y * angle.
y)))/2);
437 return hCost + (0.5 * weight1 + 0.5 * weight2);
481 Graph *g = ma->GetAbstractGraph(0);
501 GLdouble xx, yy, zz, rad;
504 map->GetOpenGLCoord(s.
x, s.
y, xx, yy, zz, rad);
506 glBegin(GL_LINE_STRIP);
507 glVertex3f(xx-old.
x*rad, yy-old.
y*rad, zz-rad/2);
510 glVertex3f(xx+old.
x*rad, yy+old.
y*rad, zz-rad/2);
513 double percOffset=0.5;
514 double lengthOffset=0.5*rad;
515 glBegin(GL_LINE_STRIP);
516 glVertex3f(xx+percOffset*old.
x*rad-old.
y*lengthOffset,
517 yy+percOffset*old.
y*rad+old.
x*lengthOffset, zz-rad/2);
518 glVertex3f(xx+old.
x*rad, yy+old.
y*rad, zz-rad/2);
520 glVertex3f(xx+percOffset*old.
x*rad+old.
y*lengthOffset,
521 yy+percOffset*old.
y*rad-old.
x*lengthOffset, zz-rad/2);
542 Graph* g = ma->GetAbstractGraph(0);
546 GLdouble xx, yy, zz, rad;
551 glColor3f(1.0, 1.0, 1.0);
554 glBegin(GL_LINE_STRIP);
555 glVertex3f(xx, yy, zz-rad/2);
558 glVertex3f(xx, yy, zz-rad/2);
564 glColor3f(1.0, 1.0, 1.0);
567 glBegin(GL_LINE_STRIP);
568 glVertex3f(xx, yy, zz-rad/2);
572 glVertex3f(xx, yy, zz-rad/2);
580 glBegin(GL_LINE_STRIP);
581 glVertex3f(xx, yy, zz-rad/2);
584 glColor3f(1.0, 1.0, 1.0);
586 glVertex3f(xx, yy, zz-rad/2);
601 case kN: s.
y-=1;
break;
602 case kS: s.
y+=1;
break;
603 case kE: s.
x+=1;
break;
604 case kW: s.
x-=1;
break;
605 case kNW: s.
y-=1; s.
x-=1;
break;
606 case kSW: s.
y+=1; s.
x-=1;
break;
607 case kNE: s.
y-=1; s.
x+=1;
break;
608 case kSE: s.
y+=1; s.
x+=1;
break;
612 Graph* g = ma->GetAbstractGraph(0);
613 node* from = ma->GetNodeFromMap(initial.
x, initial.
y);
614 node* to = ma->GetNodeFromMap(s.
x, s.
y);
641 Graph* g = ma->GetAbstractGraph(0);
645 std::vector<tDirection> directions;
646 directions.push_back(
kN);
647 directions.push_back(
kNE);
648 directions.push_back(
kE);
649 directions.push_back(
kSE);
650 directions.push_back(
kS);
651 directions.push_back(
kSW);
652 directions.push_back(
kW);
653 directions.push_back(
kNW);
655 int numDotProducts = 0;
656 double totalDotProducts = 0;
670 if (nodeVec.
x == 0 && nodeVec.
y == 0)
676 double bestDotProd = -2;
679 for (
unsigned int i=0; i<directions.size(); i++)
682 GetNextState(current, directions[i], nextThisDir);
684 if (!GetMap()->CanStep(current.
x, current.
y, nextThisDir.
x, nextThisDir.
y))
689 double dotProd = (nodeVec.
x * dirVec.
x) + (nodeVec.
y * dirVec.
y);
691 if (dotProd > bestDotProd)
693 bestDotProd = dotProd;
694 bestDir = directions[i];
698 if (bestDotProd == -2)
continue;
702 GetNextState(current, bestDir, next);
704 if (!(next==current))
715 Vector2D difference((nodeVec.
x + nextNodeVec.
x)/2, (nodeVec.
y + nextNodeVec.
y)/2);
716 double addme = sqrt(difference.
x * difference.
x + difference.
y * difference.
y);
717 totalDotProducts += addme;
722 return (totalDotProducts / (
double)(numDotProducts));
731 case kN: angle.
Set(0,-1);
break;
732 case kS: angle.
Set(0,1);
break;
733 case kE: angle.
Set(1,0);
break;
734 case kW: angle.
Set(-1,0);
break;
735 case kNW: angle.
Set(-1,-1);
break;
736 case kSW: angle.
Set(-1,1);
break;
737 case kNE: angle.
Set(1,-1);
break;
738 case kSE: angle.
Set(1,1);
break;