]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/blob - incl/pslot.hh
b9d4ff52dda6db1e55fe82312997f08d24ec04bb
[hubacji1/bcar.git] / incl / pslot.hh
1 /*! \file */
2 #ifndef BCAR_PSLOT_H
3 #define BCAR_PSLOT_H
4
5 #include <ostream>
6 #include "bcar.hh"
7
8 namespace bcar {
9
10 /*! \brief Parking slot basic class.
11  *
12  * This class contains some geometrical computations of parking slot. Parking
13  * slot consists of 4 cartesian coordinates `border` representing the border of
14  * the parking slot.
15  */
16 class ParkingSlot {
17 private:
18         Point border_[4];
19         Line entry_;
20         Line rear_;
21         Line curb_;
22         Line front_;
23 public:
24         /*! \brief Set parking slot.
25
26         \param p Point with `x`, `y` coordinates of entry side's corner.
27         \param h Direction of the entry side.
28         \param W The width of the slot.
29         \param L The length of the slot.
30         */
31         ParkingSlot(Point p, double h, double W, double L);
32         ParkingSlot(double lrx, double lry, double rrx, double rry, double rfx,
33                 double rfy, double lfx, double lfy);
34
35         /*! Get slot's length. */
36         double len() const;
37
38         /*! Get slot's width. */
39         double w() const;
40
41         /*! Get slot's left front x coordinate. */
42         double lfx() const;
43
44         /*! Get slot's left front y coordinate. */
45         double lfy() const;
46
47         /*! Get slot's left rear x coordinate. */
48         double lrx() const;
49
50         /*! Get slot's left rear y coordinate. */
51         double lry() const;
52
53         /*! Get slot's right rear x coordinate. */
54         double rrx() const;
55
56         /*! Get slot's right rear y coordinate. */
57         double rry() const;
58
59         /*! Get slot's right front x coordinate. */
60         double rfx() const;
61
62         /*! Get slot's right front y coordinate. */
63         double rfy() const;
64
65         /*! Return parking slot's orientation. */
66         double h() const;
67
68         /*! Return `true` for the parallel parking slot. */
69         bool parallel() const;
70
71         /*! Return `true` for the parking slot on the right side. */
72         bool right() const;
73
74         /*! Change side of the parking slot. */
75         void swap_side();
76
77         /*! Return `true` if car `c` is parking in slot `this`. */
78         bool parked(BicycleCar const& c) const;
79
80         /*! Return `true` if `c`'s car frame collide with `this` border. */
81         bool collide(BicycleCar const& c) const;
82
83         friend std::ostream& operator<<(std::ostream& o, ParkingSlot const& s);
84 };
85
86 } // namespace bcar
87 #endif /* BCAR_PSLOT_H */