aboutsummaryrefslogtreecommitdiff
path: root/generic/Geo.c
diff options
context:
space:
mode:
authorlecoanet2002-02-15 08:28:48 +0000
committerlecoanet2002-02-15 08:28:48 +0000
commitdfae3f0ea4e7dc63be2617b19af88b4010f68928 (patch)
tree8b283ba6819ccfc23ebcd9e3dd5fc6c51641756d /generic/Geo.c
parente14f136e0250caf818c2f6b9b9ac393db7c556d8 (diff)
downloadtkzinc-dfae3f0ea4e7dc63be2617b19af88b4010f68928.zip
tkzinc-dfae3f0ea4e7dc63be2617b19af88b4010f68928.tar.gz
tkzinc-dfae3f0ea4e7dc63be2617b19af88b4010f68928.tar.bz2
tkzinc-dfae3f0ea4e7dc63be2617b19af88b4010f68928.tar.xz
Correction des bugs de GetCirclePoints lorsque l'one demande
un arc. Passage des deltas de PointPolarToCartesian en flottant.
Diffstat (limited to 'generic/Geo.c')
-rw-r--r--generic/Geo.c41
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);
}