@@ -26,33 +26,21 @@ std::ostream& operator<<(std::ostream& out, const Point2D& p)
2626 return out;
2727}
2828
29- Point2D rotate (Point2D const & p_in, Point2D const & center,
30- double const & angle_deg)
29+ Point2D rotate (Point2D const & p_in, double const & angle_deg)
3130{
3231 const double pi = 3.14159265358979323846 ;
3332 const double angle_rad = angle_deg * pi / 180.0 ;
3433 const double s = sin (angle_rad);
3534 const double c = cos (angle_rad);
3635 Point2D p;
3736
38- // translate point back to origin:
39- /* *
40- p.x = p_in.x - center.x;
41- p.y = p_in.y - center.y;
42- **/
4337 p = p_in;
4438
4539 // rotate point
4640 double tmp = p.x * c - p.y * s;
4741 p.y = p.x * s + p.y * c;
4842 p.x = tmp;
4943
50- // translate point back:
51- /* *
52- p.x += center.x;
53- p.y += center.y;
54- **/
55-
5644 return p;
5745}
5846
@@ -70,15 +58,13 @@ bool approx(double v1, double v2)
7058
7159void testRotation (double angle)
7260{
73- const size_t grid_size = 6 ;
74- const Point2D center (0 , 0 );
75-
61+ const size_t grid_size = 6 ;
7662 std::vector<double > points;
7763
7864 // Generate rotated point grid of 1-by-1 squares.
7965 for (size_t x = 0 ; x < grid_size; ++x) {
8066 for (size_t y = 0 ; y < grid_size; ++y) {
81- Point2D p = rotate (Point2D (x, y), center, angle);
67+ Point2D p = rotate (Point2D (x, y), angle);
8268 points.push_back (p.x );
8369 points.push_back (p.y );
8470 }
@@ -146,7 +132,6 @@ void testRotation(double angle)
146132
147133TEST (Delaunator, issue_2)
148134{
149- // testRotation(0);
150135 for (double angle = 0 ; angle < 360 ; angle += .1 )
151136 testRotation (angle);
152137}
0 commit comments