\param border Array of 4 `x`, `y` values - the borderd of the parking slot.
*/
class ParkingSlot {
- private:
- double border_[4][2] = {
- {0, 0},
- {1, 0},
- {1, 2},
- {0, 2}
- };
- public:
- /*! \brief Reverse order of border coordinates.
- */
- void reverse_border();
+private:
+ double border_[4][2] = {
+ {0, 0},
+ {1, 0},
+ {1, 2},
+ {0, 2}
+ };
+public:
+ /*! \brief Reverse order of border coordinates.
+ */
+ void reverse_border();
- // slot info
- /*! \brief Return orientation of the parking slot.
+ // slot info
+ /*! \brief Return orientation of the parking slot.
- The orientation of the parking slot is computed as the
- direction from the first to the last border coordinates.
- */
- double heading() const;
- /*! \brief Return `true` if slot is parallel.
+ The orientation of the parking slot is computed as the
+ direction from the first to the last border coordinates.
+ */
+ double heading() const;
+ /*! \brief Return `true` if slot is parallel.
- There are two slot types - parallel and perpendicular.
- */
- bool parallel() const;
- /*! \brief Return `true` if slot is on the right.
+ There are two slot types - parallel and perpendicular.
+ */
+ bool parallel() const;
+ /*! \brief Return `true` if slot is on the right.
- The slot could be on right or the left side.
- */
- bool right() const;
+ The slot could be on right or the left side.
+ */
+ bool right() const;
- // getters, setters
- double x1() const { return this->border_[0][0]; }
- double y1() const { return this->border_[0][1]; }
- double x2() const { return this->border_[1][0]; }
- double y2() const { return this->border_[1][1]; }
- double x3() const { return this->border_[2][0]; }
- double y3() const { return this->border_[2][1]; }
- double x4() const { return this->border_[3][0]; }
- double y4() const { return this->border_[3][1]; }
- /*! \brief Set parking slot border.
+ // getters, setters
+ double x1() const { return this->border_[0][0]; }
+ double y1() const { return this->border_[0][1]; }
+ double x2() const { return this->border_[1][0]; }
+ double y2() const { return this->border_[1][1]; }
+ double x3() const { return this->border_[2][0]; }
+ double y3() const { return this->border_[2][1]; }
+ double x4() const { return this->border_[3][0]; }
+ double y4() const { return this->border_[3][1]; }
+ /*! \brief Set parking slot border.
- \param x1 First `x` coordinate.
- \param y1 First `y` coordinate.
- \param x2 Second `x` coordinate.
- \param y2 Second `y` coordinate.
- \param x3 Third `x` coordinate.
- \param y3 Third `y` coordinate.
- \param x4 The last (fourth) `x` coordinate.
- \param y4 The last (fourth) `y` coordinate.
- */
- void border(
- double x1, double y1,
- double x2, double y2,
- double x3, double y3,
- double x4, double y4
- ) {
- this->border_[0][0] = x1;
- this->border_[0][1] = y1;
- this->border_[1][0] = x2;
- this->border_[1][1] = y2;
- this->border_[2][0] = x3;
- this->border_[2][1] = y3;
- this->border_[3][0] = x4;
- this->border_[3][1] = y4;
- };
- /*! \brief Set parking slot.
+ \param x1 First `x` coordinate.
+ \param y1 First `y` coordinate.
+ \param x2 Second `x` coordinate.
+ \param y2 Second `y` coordinate.
+ \param x3 Third `x` coordinate.
+ \param y3 Third `y` coordinate.
+ \param x4 The last (fourth) `x` coordinate.
+ \param y4 The last (fourth) `y` coordinate.
+ */
+ void border(
+ double x1, double y1,
+ double x2, double y2,
+ double x3, double y3,
+ double x4, double y4
+ ) {
+ this->border_[0][0] = x1;
+ this->border_[0][1] = y1;
+ this->border_[1][0] = x2;
+ this->border_[1][1] = y2;
+ this->border_[2][0] = x3;
+ this->border_[2][1] = y3;
+ this->border_[3][0] = x4;
+ this->border_[3][1] = y4;
+ };
+ /*! \brief Set parking slot.
- \param x Horizontal coordinate of entry side center.
- \param y Vertical coordinate of entry side center.
- \param h The heading towards slot.
- \param w The width of the slot.
- \param l The length of the slot.
- */
- void set_slot(
- double x,
- double y,
- double h,
- double w,
- double l
- );
+ \param x Horizontal coordinate of entry side center.
+ \param y Vertical coordinate of entry side center.
+ \param h The heading towards slot.
+ \param w The width of the slot.
+ \param l The length of the slot.
+ */
+ void set_slot(
+ double x,
+ double y,
+ double h,
+ double w,
+ double l
+ );
- ParkingSlot();
- friend std::ostream &operator<<(
- std::ostream &out,
- const ParkingSlot &ps
- )
- {
- out << "[[" << ps.x1() << "," << ps.y1() << "]";
- out << ",[" << ps.x2() << "," << ps.y2() << "]";
- out << ",[" << ps.x3() << "," << ps.y3() << "]";
- out << ",[" << ps.x4() << "," << ps.y4() << "]";
- out << "]";
- return out;
- }
+ ParkingSlot();
+ friend std::ostream &operator<<(
+ std::ostream &out,
+ const ParkingSlot &ps
+ )
+ {
+ out << "[[" << ps.x1() << "," << ps.y1() << "]";
+ out << ",[" << ps.x2() << "," << ps.y2() << "]";
+ out << ",[" << ps.x3() << "," << ps.y3() << "]";
+ out << ",[" << ps.x4() << "," << ps.y4() << "]";
+ out << "]";
+ return out;
+ }
};
template <typename T> int sgn(T val) {
- return (T(0) < val) - (val < T(0));
+ return (T(0) < val) - (val < T(0));
}
#endif /* PSLOT_H */