aboutsummaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-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;