From e645b307a7a32c3c3d12989ccf6d60e324392d60 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sun, 1 Feb 2015 14:57:56 +0100 Subject: Begin work on UI --- problem.hpp | 50 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) (limited to 'problem.hpp') diff --git a/problem.hpp b/problem.hpp index 7097e0c..a41e47a 100644 --- a/problem.hpp +++ b/problem.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include "geom.hpp" @@ -8,10 +9,14 @@ struct obstacle { circle c; }; -struct hilare_a { // System A +struct hilare_a_param { // paramètres globaux double l; double r_c_car, r_c_trolley; +}; + +struct hilare_a { // System A + hilare_a_param *param; // position actuelle double x, y, theta, phi; @@ -19,16 +24,16 @@ struct hilare_a { // System A vec pos() const { return vec(x, y); } vec dir() const { return vec::from_polar(1, theta); } - vec pos_trolley() const { - return pos() + vec::from_polar(l, theta + phi + M_PI); - } vec dir_trolley() const { - return vec::from_polar(1, theta + phi); + return vec::from_polar(1, theta + phi + M_PI); + } + vec pos_trolley() const { + return pos() + param->l * dir_trolley(); } }; struct problem { - std::vector map; + std::vector obstacles; hilare_a begin_pos, end_pos; }; @@ -45,10 +50,18 @@ struct hilare_a_mvt { // - avancer/reculer sur le cercle (c'est l'angle domega) hilare_a from, to; - vec center; + + bool is_arc; // true = circle arc ; false = straight line (phi = 0) + double dtheta_before; // rotation de la voiture sur elle-même avant + + // CAS D'UN ARC DE CERCLE + vec center; double domega; // angle parcouru sur le cercle de centre center + // CAS D'UN DEPLACEMENT EN LIGNE DROITE + double ds; // longueur par + double length(); // length of a movement bool intersects(const obstacle& o) const; // intersects an obstacle ? @@ -57,6 +70,7 @@ struct hilare_a_mvt { struct solution { std::vector movement; + solution() {} solution(const std::vector &m) : movement(m) {} // simple direct solution from A to B, takes into account no obstacles @@ -64,9 +78,27 @@ struct solution { // check if a solution intersects an obstacle of problem bool intersects(const problem &p) const; +}; + +struct solver_internal { + // intermediate data for the solver + // represents a graph of randomly chosen positions and simple solutions between them + std::vector pts; + std::map > paths; +}; + +class solver { + // mutex-protected asynchronous structure + + private: + //todo + + public: + solver(); - // calculate a solution - static solution make_solution(const problem &p); + void start(const problem &p); + bool finished(); + solution get_solution(); }; -- cgit v1.2.3