]> rtime.felk.cvut.cz Git - hubacji1/bcar.git/blobdiff - api/pslot.h
Add slot border getter/setter
[hubacji1/bcar.git] / api / pslot.h
index bfd984f715135d024937290021f52fc2255a0d26..65d888725628521a6441aba975c1a474e4b823d2 100644 (file)
@@ -3,11 +3,57 @@
 
 /*! \brief Parking slot basic class.
 
-This class contains some geometrical computations of parking slot.
+This class contains some geometrical computations of parking slot. Parking slot
+consists of 4 cartesian coordinates `border` representing the border of the
+parking slot.
+
+\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:
+                // 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;
+                };
+
                 ParkingSlot();
 };