aboutsummaryrefslogtreecommitdiffstats
path: root/problem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'problem.cpp')
-rw-r--r--problem.cpp10
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;
}