From cd601db8bf7c3f8a8af398c1a7ab35ee9e352e83 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 2 Feb 2015 00:43:24 +0100 Subject: Fix. --- problem.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/problem.cpp b/problem.cpp index bc8f1d0..e37595b 100644 --- a/problem.cpp +++ b/problem.cpp @@ -142,7 +142,7 @@ vector 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 sol; vec p1 = cca + vec::from_polar((pos_a.pos() - cca).norm(), (pos_a.pos() - cca).angle() + domega1); @@ -185,7 +185,7 @@ vector solution::direct_sol(const hilare_a &pos_a, const hilare_a &pos } std::vector solution::direct_sol_r(const hilare_a &pos_a, const hilare_a &pos_b) { - std::vector ret = direect_sol(pos_a, pos_b); + std::vector 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 }; @@ -242,7 +242,7 @@ bool solution::intersects(const problem &p) const { } double solution::length() { - double x; + double x = 0; for (auto& m: movement) { x += m.length(); } @@ -416,7 +416,7 @@ void solver_internal::step(const problem &p) { void solver_internal::find_direct_path(int a, int b, const problem &p) { vector 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; } -- cgit v1.2.3 From cbcc1513db57c2086fbfc469b3bb064975b297b6 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 2 Feb 2015 00:46:28 +0100 Subject: Fix --- problem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/problem.cpp b/problem.cpp index 0651808..1437729 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 ; } -- cgit v1.2.3