4 /*! \brief Parking slot basic class.
6 This class contains some geometrical computations of parking slot. Parking slot
7 consists of 4 cartesian coordinates `border` representing the border of the
10 \param border Array of 4 `x`, `y` values - the borderd of the parking slot.
14 double border_[4][2] = {
22 /*! \brief Return orientation of the parking slot.
24 The orientation of the parking slot is computed as the
25 direction from the first to the last border coordinates.
27 double heading() const;
28 /*! \brief Return `true` if slot is parallel.
30 There are two slot types - parallel and perpendicular.
32 bool parallel() const;
33 /*! \brief Return `true` if slot is on the right.
35 The slot could be on right or the left side.
40 double x1() const { return this->border_[0][0]; }
41 double y1() const { return this->border_[0][1]; }
42 double x2() const { return this->border_[1][0]; }
43 double y2() const { return this->border_[1][1]; }
44 double x3() const { return this->border_[2][0]; }
45 double y3() const { return this->border_[2][1]; }
46 double x4() const { return this->border_[3][0]; }
47 double y4() const { return this->border_[3][1]; }
48 /*! \brief Set parking slot border.
50 \param x1 First `x` coordinate.
51 \param y1 First `y` coordinate.
52 \param x2 Second `x` coordinate.
53 \param y2 Second `y` coordinate.
54 \param x3 Third `x` coordinate.
55 \param y3 Third `y` coordinate.
56 \param x4 The last (fourth) `x` coordinate.
57 \param y4 The last (fourth) `y` coordinate.
65 this->border_[0][0] = x1;
66 this->border_[0][1] = y1;
67 this->border_[1][0] = x2;
68 this->border_[1][1] = y2;
69 this->border_[2][0] = x3;
70 this->border_[2][1] = y3;
71 this->border_[3][0] = x4;
72 this->border_[3][1] = y4;
76 friend std::ostream &operator<<(
81 out << "[[" << ps.x1() << "," << ps.y1() << "]";
82 out << ",[" << ps.x2() << "," << ps.y2() << "]";
83 out << ",[" << ps.x3() << "," << ps.y3() << "]";
84 out << ",[" << ps.x4() << "," << ps.y4() << "]";
90 template <typename T> int sgn(T val) {
91 return (T(0) < val) - (val < T(0));