6 /*! \brief Parking slot basic class.
8 This class contains some geometrical computations of parking slot. Parking slot
9 consists of 4 cartesian coordinates `border` representing the border of the
12 \param border Array of 4 `x`, `y` values - the borderd of the parking slot.
16 double border_[4][2] = {
23 /*! \brief Reverse order of border coordinates.
25 void reverse_border();
28 /*! \brief Return orientation of the parking slot.
30 The orientation of the parking slot is computed as the
31 direction from the first to the last border coordinates.
33 double heading() const;
34 /*! \brief Return `true` if slot is parallel.
36 There are two slot types - parallel and perpendicular.
38 bool parallel() const;
39 /*! \brief Return `true` if slot is on the right.
41 The slot could be on right or the left side.
46 double x1() const { return this->border_[0][0]; }
47 double y1() const { return this->border_[0][1]; }
48 double x2() const { return this->border_[1][0]; }
49 double y2() const { return this->border_[1][1]; }
50 double x3() const { return this->border_[2][0]; }
51 double y3() const { return this->border_[2][1]; }
52 double x4() const { return this->border_[3][0]; }
53 double y4() const { return this->border_[3][1]; }
54 /*! \brief Set parking slot border.
56 \param x1 First `x` coordinate.
57 \param y1 First `y` coordinate.
58 \param x2 Second `x` coordinate.
59 \param y2 Second `y` coordinate.
60 \param x3 Third `x` coordinate.
61 \param y3 Third `y` coordinate.
62 \param x4 The last (fourth) `x` coordinate.
63 \param y4 The last (fourth) `y` coordinate.
71 this->border_[0][0] = x1;
72 this->border_[0][1] = y1;
73 this->border_[1][0] = x2;
74 this->border_[1][1] = y2;
75 this->border_[2][0] = x3;
76 this->border_[2][1] = y3;
77 this->border_[3][0] = x4;
78 this->border_[3][1] = y4;
80 /*! \brief Set parking slot.
82 \param x Horizontal coordinate of entry side center.
83 \param y Vertical coordinate of entry side center.
84 \param h The heading towards slot.
85 \param w The width of the slot.
86 \param l The length of the slot.
97 friend std::ostream &operator<<(
102 out << "[[" << ps.x1() << "," << ps.y1() << "]";
103 out << ",[" << ps.x2() << "," << ps.y2() << "]";
104 out << ",[" << ps.x3() << "," << ps.y3() << "]";
105 out << ",[" << ps.x4() << "," << ps.y4() << "]";
111 template <typename T> int sgn(T val) {
112 return (T(0) < val) - (val < T(0));