]> rtime.felk.cvut.cz Git - hubacji1/psp.git/blob - api/psp.h
65d5747a6dc4cfd0b6803a8ca6092da77f5b17f9
[hubacji1/psp.git] / api / psp.h
1 #ifndef PSP_H
2 #define PSP_H
3
4 #include <tuple>
5
6 #include "bcar.h"
7 #include "pslot.h"
8
9 /*! \brief Parking Slot Planner basic class.
10
11 \param cc Current bicycle car.
12 \param ps Parking slot.
13 \param gc Goal car.
14 */
15 class PSPlanner {
16         private:
17                 BicycleCar cc_;
18                 BicycleCar gc_;
19                 ParkingSlot ps_;
20         public:
21                 bool collide();
22
23                 // find entry
24                 /*! \brief Find entry to the parking slot.
25                 */
26                 void fe();
27                 /*! \brief Find entry to slot by reverse approach.
28
29                 See `Vorobieva2015` for more information.
30                 */
31                 void fer();
32
33                 // getters, setters
34                 BicycleCar &cc() { return this->cc_; }
35                 BicycleCar &gc() { return this->gc_; }
36                 ParkingSlot &ps() { return this->ps_; }
37
38                 PSPlanner();
39 };
40
41 /*! \brief Return intersection of two line segments.
42
43 The output is tuple `std::tuple<bool, double, double>`, where the first
44 value is true when there is an intersection and false otherwise. The
45 second and third parameters in the return tuple are coordinates of the
46 intersection.
47
48 \see https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
49
50 \param x1 First line segment first `x` coordinate.
51 \param y1 First line segment first `y` coordinate.
52 \param x2 First line segment second `x` coordinate.
53 \param y2 First line segment second `y` coordinate.
54 \param x3 Second line segment first `x` coordinate.
55 \param y3 Second line segment first `y` coordinate.
56 \param x4 Second line segment second `x` coordinate.
57 \param y4 Second line segment second `y` coordinate.
58 */
59 std::tuple<bool, double, double> intersect(
60         double x1, double y1,
61         double x2, double y2,
62         double x3, double y3,
63         double x4, double y4
64 );
65
66 #endif /* PSP_H */