*/
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);
};
/*! Set pose (`x`, `y`, and `h`.) */
void set_pose(Pose const& p);
- /*! \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, Pose const& p);
}
}
+void
+Point::rotate(Point const& c, double const angl)
+{
+ double px = this->x();
+ double py = this->y();
+ px -= c.x();
+ py -= c.y();
+ double nx = px * cos(angl) - py * sin(angl);
+ double ny = px * sin(angl) + py * cos(angl);
+ this->x(nx + c.x());
+ this->y(ny + c.y());
+}
+
std::ostream&
operator<<(std::ostream& out, Point const& p)
{
void
Pose::rotate(Point const& c, double const angl)
{
- double px = this->x();
- double py = this->y();
- px -= c.x();
- py -= c.y();
- double nx = px * cos(angl) - py * sin(angl);
- double ny = px * sin(angl) + py * cos(angl);
+ Point::rotate(c, angl);
this->h(this->h() + angl);
- this->x(nx + c.x());
- this->y(ny + c.y());
}
std::ostream&