diff options
author | Jean Fabre-Monplaisir <jean-isaac-fm@live.fr> | 2015-02-02 01:51:35 +0100 |
---|---|---|
committer | Jean Fabre-Monplaisir <jean-isaac-fm@live.fr> | 2015-02-02 01:51:35 +0100 |
commit | 0275479b6a8c8cb7664ee840cd8428ddd7ab3073 (patch) | |
tree | 2eee7eb2154e9538565c5af5c10a4261ead56632 | |
parent | 3824e47b6b6274b614cfd63098f506ccd356b25a (diff) | |
parent | cbcc1513db57c2086fbfc469b3bb064975b297b6 (diff) | |
download | Robotique-Projet-0275479b6a8c8cb7664ee840cd8428ddd7ab3073.tar.gz Robotique-Projet-0275479b6a8c8cb7664ee840cd8428ddd7ab3073.zip |
Merge branch 'master' of github.com:Alexis211/Robotique
-rw-r--r-- | problem.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/problem.cpp b/problem.cpp index 985ff26..e51aa95 100644 --- a/problem.cpp +++ b/problem.cpp @@ -12,7 +12,7 @@ using namespace std; double hilare_a_mvt::length() { // returns length traveled by the car - if (is_arc) return domega * (center - from.pos()).norm(); + if (is_arc) return fabs(domega) * (center - from.pos()).norm(); return ds ; } @@ -144,7 +144,7 @@ vector<solution> solution::direct_sol(const hilare_a &pos_a, const hilare_a &pos << ", domega2: " << domega2 << ", xx:" << xx << endl; - if (fabs(xx) < 0.01 || fabs(xx - 2*M_PI) < 0.01 && fabs(xx + 2*M_PI) < 0.01) { + if (fabs(xx) < 0.01 || fabs(xx - 2*M_PI) < 0.01 || fabs(xx + 2*M_PI) < 0.01) { vector<hilare_a_mvt> sol; vec p1 = cca + vec::from_polar((pos_a.pos() - cca).norm(), (pos_a.pos() - cca).angle() + domega1); @@ -187,7 +187,7 @@ vector<solution> solution::direct_sol(const hilare_a &pos_a, const hilare_a &pos } std::vector<solution> solution::direct_sol_r(const hilare_a &pos_a, const hilare_a &pos_b) { - std::vector<solution> ret = direect_sol(pos_a, pos_b); + std::vector<solution> ret = direct_sol(pos_a, pos_b); const int nnn = 8; const double xa[nnn] = { -1, -0.8, -0.6, -0.4, 0.4, 0.6, 0.8, 1 }; @@ -244,7 +244,7 @@ bool solution::intersects(const problem &p) const { } double solution::length() { - double x; + double x = 0; for (auto& m: movement) { x += m.length(); } @@ -418,7 +418,7 @@ void solver_internal::step(const problem &p) { void solver_internal::find_direct_path(int a, int b, const problem &p) { vector<solution> s = solution::direct_sol_r(pts[a], pts[b]); int best = -1; - for (int k = 0; k < s.size(); k++) { + for (unsigned k = 0; k < s.size(); k++) { if (s[k].movement.size() > 0 && !s[k].intersects(p)) { if (best == -1 || s[k].length() < s[best].length()) best = k; } |