aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-02-01 18:07:27 +0100
committerAlex Auvolat <alex.auvolat@ens.fr>2015-02-01 18:07:27 +0100
commitcacec4dbb8b5cc017b9c6d9975f8f792db13cc7a (patch)
tree00a3a31b475c678dbafca8b73f0ac26f14d15bfb
parent29158da41e7943ea8019efdbff70c994fb1c73e9 (diff)
parent93cd8ba7c9ea2ee22bfcb828cd5190c4662a05b0 (diff)
downloadRobotique-Projet-cacec4dbb8b5cc017b9c6d9975f8f792db13cc7a.tar.gz
Robotique-Projet-cacec4dbb8b5cc017b9c6d9975f8f792db13cc7a.zip
Merge branch 'master' of https://github.com/Alexis211/Robotique
-rw-r--r--geom.hpp7
-rw-r--r--problem.cpp33
-rw-r--r--problem.hpp8
3 files changed, 41 insertions, 7 deletions
diff --git a/geom.hpp b/geom.hpp
index fc9f32c..06b9e65 100644
--- a/geom.hpp
+++ b/geom.hpp
@@ -181,16 +181,19 @@ struct angular_sector {
angular_sector(circarc i, circarc o) : inner(i), outer(o) {
assert(i.c.c == o.c.c);
+ assert(i.theta1 == o.theta1);
+ assert(i.theta2 == o.theta2);
+
}
bool is_in_sector(vec p) const{
- //TODO
+
return false;
}
double dist(vec p) const{
if (is_in_sector(p)) return 0;
//TODO
- return 29 ;
+ return 42 ;
}
};
/* vim: set ts=4 sw=4 tw=0 noet :*/
diff --git a/problem.cpp b/problem.cpp
index 3169751..11f4d8e 100644
--- a/problem.cpp
+++ b/problem.cpp
@@ -11,12 +11,39 @@ using namespace std;
double hilare_a_mvt::length() {
// returns length traveled by the car
- // TODO : two cases
- return domega * (center - from.pos()).norm();
+ if (is_arc) return domega * (center - from.pos()).norm();
+ return ds ;
+}
+
+bool hilare_a::intersects(const obstacle &o) const {
+
+ if((pos()-o.c.c).norm() < o.c.r + param->r_c_car)return true ;
+ if((pos_trolley()-o.c.c).norm() < o.c.r + param->r_c_trolley)return true ;
+ if(segment(pos(),pos_trolley()).dist(o.c.c) < o.c.r)return true ;
+ return false ;
}
bool hilare_a_mvt::intersects(const obstacle &o) const {
- // TODO
+ hilare_a_param *p = from.param;
+ vec pos_init = from.pos();
+ vec pos_init_trolley = from.pos_trolley();
+ if(is_arc){
+ double r_min =
+ min((pos_init - center).norm()-(p->r_c_car),
+ (pos_init_trolley - center).norm()-(p->r_c_trolley));
+ double r_max =
+ max((pos_init - center).norm()+(p->r_c_car),
+ (pos_init_trolley - center).norm()+(p->r_c_trolley));
+ //TODO
+ double theta1 = 0;
+ double theta2 = 0;
+ angular_sector sector = angular_sector(circarc(circle(center,r_min), theta1, theta2), circarc(circle(center,r_max), theta1, theta2));
+ if (sector.dist(o.c.c)<=o.c.r)return true;
+ if (from.intersects(o)) return true;
+ if (to.intersects(o)) return true;
+ return false;
+
+ }
return false;
}
diff --git a/problem.hpp b/problem.hpp
index 8851fa2..6eadd0a 100644
--- a/problem.hpp
+++ b/problem.hpp
@@ -32,6 +32,9 @@ struct hilare_a { // System A
vec pos_trolley() const {
return pos() + param->l * dir_trolley();
}
+
+ bool intersects(const obstacle &o) const; // intersects an obstacle ?
+
};
struct problem {
@@ -66,9 +69,10 @@ struct hilare_a_mvt {
double ds; // longueur par
double length(); // length of a movement
+
+ bool intersects(const obstacle &o) const; // intersects an obstacle ?
- bool intersects(const obstacle& o) const; // intersects an obstacle ?
- bool intersects(const problem &p) const; // intersects any obstacle on the map ?
+ bool intersects(const problem &p) const; // intersects any obstacle on the map ?
};
struct solution {