aboutsummaryrefslogtreecommitdiff
path: root/generic/Geo.c
diff options
context:
space:
mode:
authorlecoanet2003-01-14 10:52:15 +0000
committerlecoanet2003-01-14 10:52:15 +0000
commite0562b5a186612c3443c01527def0e6f30583bfb (patch)
tree3c2a5b9a6664ca714a481c41ebd6f7d869c1cb88 /generic/Geo.c
parent4a8d47f1b9dfc7fecc3e31ebfa80a388318d86a9 (diff)
downloadtkzinc-e0562b5a186612c3443c01527def0e6f30583bfb.zip
tkzinc-e0562b5a186612c3443c01527def0e6f30583bfb.tar.gz
tkzinc-e0562b5a186612c3443c01527def0e6f30583bfb.tar.bz2
tkzinc-e0562b5a186612c3443c01527def0e6f30583bfb.tar.xz
* (GetBezierPoints): Corrige le test de fin de r�cursion. Il �tait
vraiment erron� pour certaines configurations de points controle. Le nouveau code est probablement plus lent mais correct.
Diffstat (limited to 'generic/Geo.c')
-rw-r--r--generic/Geo.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/generic/Geo.c b/generic/Geo.c
index 8cd2edf..7af09d8 100644
--- a/generic/Geo.c
+++ b/generic/Geo.c
@@ -1992,26 +1992,21 @@ GetBezierPoints(ZnPoint *p1,
ZnList to_points,
double eps)
{
- ZnReal dist2;
- ZnPoint mid_segm, mid_cord, delta;
+ ZnReal dist;
- /*
- * Compute distance between coord center and curve at t = 0.5
- */
- mid_segm.x = (p1->x + 3*c1->x + 3*c2->x + p2->x) / 8.0;
- mid_segm.y = (p1->y + 3*c1->y + 3*c2->y + p2->y) / 8.0;
- mid_cord.x = (p1->x + p2->x) / 2.0;
- mid_cord.y = (p1->y + p2->y) / 2.0;
- delta.x = mid_segm.x - mid_cord.x;
- delta.y = mid_segm.y - mid_cord.y;
- dist2 = delta.x*delta.x + delta.y*delta.y;
-
- if (dist2 > eps) {
- ZnPoint new_c1, new_c2;
+ dist = LineToPointDist(p1, p2, c1);
+ if ((dist < eps) && ((c1->x != c2->x) || (c1->y != c2->y))) {
+ dist = LineToPointDist(p1, p2, c2);
+ }
+
+ if (dist > eps) {
+ ZnPoint mid_segm, new_c1, new_c2;
/*
* Subdivide the curve at t = 0.5
* and compute each new curve.
*/
+ mid_segm.x = (p1->x + 3*c1->x + 3*c2->x + p2->x) / 8.0;
+ mid_segm.y = (p1->y + 3*c1->y + 3*c2->y + p2->y) / 8.0;
new_c1.x = (p1->x + c1->x) / 2.0;
new_c1.y = (p1->y + c1->y) / 2.0;
new_c2.x = (p1->x + 2*c1->x + c2->x) / 4.0;