diff options
Diffstat (limited to 'generic/Geo.c')
-rw-r--r-- | generic/Geo.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/generic/Geo.c b/generic/Geo.c index 91c092c..8e2105e 100644 --- a/generic/Geo.c +++ b/generic/Geo.c @@ -1194,17 +1194,17 @@ void PointPolarToCartesian(ZnReal heading, int rho, int theta, - int *delta_x, - int *delta_y) + ZnDim *delta_x, + ZnDim *delta_y) { - double to_angle; + ZnReal to_angle; /* Compute angle in trigonometric system */ to_angle = DegreesToRadian(theta) + heading - M_PI_2; /* to_angle = heading - DegreesToRadian(theta);*/ /* Compute cartesian coordinates */ - *delta_x = (int) (rho * cos(to_angle)); - *delta_y = (int) (rho * sin(to_angle)); + *delta_x = rho * cos(to_angle); + *delta_y = rho * sin(to_angle); } /* @@ -2244,11 +2244,9 @@ GetCirclePoints(int type, /* * normalize start_angle and end_angle. */ - start_angle = fmod(start_angle, 2.0*M_PI); if (start_angle < 0.0) { start_angle += 2.0*M_PI; } - end_angle = fmod(end_angle, 2.0*M_PI); if (end_angle < 0.0) { end_angle += 2.0*M_PI; } @@ -2256,8 +2254,11 @@ GetCirclePoints(int type, if (start_angle == end_angle) { type = 3; } - end_angle += 2.0*M_PI; + iangle = start_angle; + start_angle = end_angle; + end_angle = iangle; } + start_angle = fmod(start_angle, 2.0*M_PI); } /* @@ -2276,21 +2277,27 @@ GetCirclePoints(int type, iangle = 2*M_PI / (num_p-1); start_p.x = cos(start_angle); start_p.y = sin(start_angle); + ZnListAdd(point_list, &start_p, ZnListTail); i = start_angle / iangle; if ((i * iangle) < start_angle) { i++; } - p = &p_from[i]; - while (start_angle < end_angle) { - ZnListAdd(point_list, &p[i], ZnListTail); - start_angle += iangle; - i++; - if (i == num_p-1) { - i = 0; + while (1) { + if (start_angle + iangle < end_angle) { + if (i == num_p-1) { + i = 0; + } + ZnListAdd(point_list, &p_from[i], ZnListTail); + start_angle += iangle; + i++; + } + else { + wp.x = cos(end_angle); + wp.y = sin(end_angle); + ZnListAdd(point_list, &wp, ZnListTail); + break; } } - wp.x = cos(end_angle); - wp.y = sin(end_angle); if (type == 1) { ZnListAdd(point_list, &start_p, ZnListTail); } |