aboutsummaryrefslogtreecommitdiff
path: root/problem.cpp
diff options
context:
space:
mode:
authorJean Fabre-Monplaisir <jean-isaac-fm@live.fr>2015-02-01 19:04:55 +0100
committerJean Fabre-Monplaisir <jean-isaac-fm@live.fr>2015-02-01 19:04:55 +0100
commit2cb65f6726bbdecdc57b1544fe11fa6c586783dc (patch)
treeefd18989407339eed5cca0092188294fbf2e0046 /problem.cpp
parente95dc022cdd0a22f1e65e9500c73b59a2fc3ea2c (diff)
downloadRobotique-Projet-2cb65f6726bbdecdc57b1544fe11fa6c586783dc.tar.gz
Robotique-Projet-2cb65f6726bbdecdc57b1544fe11fa6c586783dc.zip
begin detection collision
Diffstat (limited to 'problem.cpp')
-rw-r--r--problem.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/problem.cpp b/problem.cpp
index 25061c5..fb7670b 100644
--- a/problem.cpp
+++ b/problem.cpp
@@ -8,11 +8,39 @@ using namespace std;
double hilare_a_mvt::length() {
// returns length traveled by the car
- 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;
}