Go to the documentation of this file.
16 double xMin = DBL_MAX;
17 double xMax = -DBL_MAX;
18 double yMin = DBL_MAX;
19 double yMax = -DBL_MAX;
23 std::vector<double> speed;
27 FILE *f = fopen(coordinates,
"r");
29 std::vector<double> xloc, yloc;
30 double minx = DBL_MAX, maxx=-DBL_MAX, miny=DBL_MAX, maxy=-DBL_MAX;
40 if (3 != sscanf(line,
"v %d %lf %lf", &
id, &x1, &y1))
51 if (x1 > maxx) maxx = x1;
52 if (x1 < minx) minx = x1;
53 if (y1 > maxy) maxy = y1;
54 if (y1 < miny) miny = y1;
58 std::cout<<
"Xloc and yloc before scaling\n"<<xloc[1]<<
" "<<yloc[1];
60 printf(
"x between (%f, %f), y between (%f, %f)\n",
61 minx, maxx, miny, maxy);
63 printf(
"Scale is %f\n",
scale);
64 double xoff = (maxx-minx)-
scale;
65 double yoff = (maxy-miny)-
scale;
67 for (
unsigned int x = 0; x < xloc.size(); x++)
72 xloc[x] = xloc[x]*2-1+xoff/
scale;
76 yloc[x] = yloc[x]*2-1;
77 yloc[x] = -yloc[x]+yoff/
scale;
81 else if(xloc[x] > xMax)
86 else if(yloc[x] > yMax)
101 std::cout<<
"xMin is "<<xMin<<
" yMin is "<<yMin<<
" xMax is "<<xMax<<
" yMax is "<<yMax<<std::endl;
102 std::cout<<
" min x is "<<minx/
scale + xoff;
103 std::cout<<
" max x is "<<maxx/
scale + xoff;
104 std::cout<<
" min y is "<<miny/
scale + yoff;
105 std::cout<<
" max y is "<<maxy/
scale + yoff;
109 f = fopen(graph,
"r");
122 sscanf(line,
"a %d %d %Lf", &x1, &y1,&e);
133 long double dist =
scale*sqrtf((xCoord1-xCoord2)*(xCoord1-xCoord2) + (yCoord1-yCoord2)*(yCoord1-yCoord2))/2;
138 printf(
"**FOUND ZERO-COST EDGE\n");
140 printf(
"**FOUND SELF EDGE\n");
145 speed.push_back(dist/e);
157 std::cout<<
"minE "<<minE <<
"\n";
160 std::cout<<
"closed the file\n";
163 std::cout<<
"created graph environment\n";
168 maxSpeed = *(std::max_element(speed.begin(),speed.end()));
170 maxSpeed = *(std::max_element(speed.begin(),speed.end()));
173 std::cout<<
"\n Invalid graph type";
177 printf(
" max element %lf \n",
maxSpeed);
236 return scale*sqrt((aX-bX)*(aX-bX)+(aY-bY)*(aY-bY))/(2*
maxSpeed);
241 return ge->
GCost(node1, node2);
void SetLabelF(unsigned int index, double val) const
virtual void GLDrawPath(const std::vector< state > &x) const
virtual void OpenGLDraw() const
void setWeight(double val)
virtual void GetSuccessors(const graphState &stateID, std::vector< graphState > &neighbors) const
virtual uint64_t GetActionHash(neighbor act) const
virtual void GLDrawPath(const std::vector< intersection > &x) const
virtual void GetSuccessors(const intersection &nodeID, std::vector< intersection > &neighbors) const
virtual double GCost(const intersection &node1, const intersection &node2) const
node * GetNode(unsigned long num)
virtual bool GoalTest(const intersection &node, const intersection &goal) const
virtual double HCost(const intersection &node1, const intersection &node2) const
Heuristic value between two arbitrary nodes.
virtual void ApplyAction(intersection &s, neighbor a) const
virtual void SetColor(const rgbColor &r) const
virtual neighbor GetAction(const intersection &s1, const intersection &s2) const
virtual void GetColor(GLfloat &rr, GLfloat &g, GLfloat &b, GLfloat &t) const
virtual void SetColor(GLfloat rr, GLfloat g, GLfloat b, GLfloat t=1.0) const
virtual bool InvertAction(graphMove &a) const
virtual void GetStateFromHash(uint64_t parent, intersection &s) const
virtual void ApplyAction(graphState &s, graphMove a) const
virtual void OpenGLDraw() const
virtual rgbColor GetColor() const
virtual double GCost(const graphState &state1, const graphState &state2) const
double GetLabelF(unsigned int index) const
virtual uint64_t GetMaxHash() const
virtual uint64_t GetActionHash(graphMove act) const
virtual uint64_t GetStateHash(const intersection &node) const
virtual bool InvertAction(neighbor &a) const
virtual graphMove GetAction(const graphState &s1, const graphState &s2) const
virtual void GetActions(const intersection &nodeID, std::vector< neighbor > &actions) const
virtual void GetActions(const graphState &stateID, std::vector< graphMove > &actions) const
edge * findDirectedEdge(unsigned int from, unsigned int to)
bool fequal(double a, double b, double tolerance=TOLERANCE)
Nodes to be stored within a Graph.
RoadMap(const char *graph, const char *coordinates, bool time)
Edge class for connections between node in a Graph.