return (T(0) < val) - (val < T(0));
}
+class Line;
+
class Point {
private:
double x_ = 0.0;
* \param poly Polygon to consider.
*/
bool inside_of(std::vector<Point> const& poly) const;
+
+ /*! \brief Return `true` if on the right side of the plane.
+ *
+ * The plane is given by the line `li`, where `li->fp()` is the base
+ * point and the direction is given by `li->lp() - li->fp()`.
+ *
+ * \param li The plane to consider is given by `li`.
+ */
+ bool on_right_side_of(Line const& li) const;
+
+ /*! \brief Rotate self around the point.
+
+ \param c Rotation center `Point`.
+ \param angl Angle of rotation.
+ */
+ void rotate(Point const& c, double const angl);
+
+ friend std::ostream& operator<<(std::ostream& out, Point const& p);
};
class Line {
*/
bool intersects_with(Point const& c, double const r);
- /*! \brief Return if point `p` is on the right side of the plane.
- *
- * The plane is given by the line `this`, where `this->fp()` is the base
- * point and the direction is given by `this->lp() - this->fp()`.
- *
- * \param p The point to consider.
- */
- bool is_on_right_side(Point const& p) const;
+ double len() const;
};
/*! Store coordinates `x`, `y`, and heading `h`. */
-class Pose {
+class Pose : public virtual Point {
private:
- double x_ = 0.0;
- double y_ = 0.0;
double h_ = 0.0;
public:
- /*! Get horizontal coordinate. */
- double x() const;
-
- /*! Set horizontal coordinate. */
- void x(double x);
-
- /*! Get vertical coordinate. */
- double y() const;
-
- /*! Set vertical coordinate. */
- void y(double y);
+ Pose(double x, double y, double h);
+ Pose();
/*! Get heading in the interval [-pi, +pi] radians. */
double h() const;
/*! Set heading in radians. It's recomputed to [-pi, +pi]. */
void h(double h);
- /*! \brief Rotate self around the point.
+ /*! Set pose (`x`, `y`, and `h`.) */
+ void set_pose(Pose const& p);
- \param c Rotation center `Point`.
- \param angl Angle of rotation.
- */
void rotate(Point const& c, double const angl);
friend std::ostream& operator<<(std::ostream& out, Pose const& p);
};
+class PoseRange : public virtual Pose {
+private:
+ double e_ = 0.0;
+ using Pose::h;
+public:
+ /*! Get heading's begin in the interval [-pi, +pi] radians. */
+ double b() const;
+
+ /*! Set heading's begin in radians. It's recomputed to [-pi, +pi]. */
+ void b(double b);
+
+ /*! Get heading's end in the interval [-pi, +pi] radians. */
+ double e() const;
+
+ /*! Set heading's end in radians. It's recomputed to [-pi, +pi]. */
+ void e(double e);
+
+ void rotate(Point const& c, double const angl);
+
+ friend std::ostream& operator<<(std::ostream& out, PoseRange const& p);
+};
+
/*! \brief Store car size.
*
* - Default is https://en.wikipedia.org/wiki/Fiat_Punto
* radius.
*/
double mtr() const;
-};
-
-/*! Store car motion. */
-class CarMove {
-private:
- double speed = 0.0;
- double steer = 0.0;
-public:
- /*! Get speed. */
- double sp() const;
-
- /*! Set speed. */
- void sp(double sp);
-
- /*! Get steer. */
- double st() const;
-
- /*! Set steer. */
- void st(double st);
-};
-
-/*! \brief Geometrical computations of a bicycle car.
- *
- * - `x()` and `y()` methods returns coordinates of rear axle center.
- */
-class BicycleCar : public Pose, public CarSize, public CarMove {
-private:
-public:
- /*! \brief Return `false` if `bc` is not achievable.
- *
- * When `false` is returned the `bc` may still be drivable, but not
- * trivially, i.e. by "line segment - circle arc - line segment".
- *
- * \param bc The bicycle car to achieve.
- * \param b The beginning of the heading range.
- * \param e The end of the heading range.
- */
- bool drivable(BicycleCar const& bc, double b, double e) const;
- bool drivable(BicycleCar const& bc) const;
/*! \brief Return inner radius.
*
* \see https://www.ma.rhul.ac.uk/SRBparking
*/
double perfect_parking_slot_len() const;
+};
+
+/*! Store car motion. */
+class CarMove {
+private:
+ double speed = 0.0;
+ double steer = 0.0;
+public:
+ /*! Get speed. */
+ double sp() const;
+
+ /*! Set speed. */
+ void sp(double sp);
+
+ /*! Get steer. */
+ double st() const;
+
+ /*! Set steer. */
+ void st(double st);
+};
+
+/*! \brief Geometrical computations of a bicycle car.
+ *
+ * - `x()` and `y()` methods returns coordinates of rear axle center.
+ */
+class BicycleCar : public virtual Pose, public virtual CarSize,
+ public virtual CarMove {
+private:
+public:
+ /*! \brief Return `false` if `bc` is not achievable.
+ *
+ * When `false` is returned the `bc` may still be drivable, but not
+ * trivially, i.e. by "line segment - circle arc - line segment".
+ *
+ * \param p `PoseRange` (resp. `Pose`) to achieve.
+ */
+ bool drivable(PoseRange const& p) const;
+ bool drivable(Pose const& p) const;
/*! Set maximum steering angle. */
void set_max_steer();