Skip to content

Commit

Permalink
Intersector: fix for quadratic Bezier curves
Browse files Browse the repository at this point in the history
- Missed parenthesis mistake in Bhaskara solution for quadratic
equations
- Forgot to return correct signal according to curve direction for
some 'special' cases

This is another fix for #442
  • Loading branch information
rodolforg committed Oct 13, 2021
1 parent ab63c0c commit 3f4a697
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions synfig-core/src/synfig/rendering/primitive/intersector.cpp
Expand Up @@ -161,8 +161,13 @@ class Intersector::CurveArray
return 0;

// degenerate accept - to the right and crossing the base line
if (p[0] > xmax)
return (p[1] <= ymax && p[1] >= ymin);
if (p[0] > xmax) {
if (points[2][1] > points[0][1])
return 1;
if (points[2][1] < points[0][1])
return -1;
return 0;
}

// solve for curve = y

Expand All @@ -188,8 +193,8 @@ class Intersector::CurveArray
// if there are double/no roots - no intersections (in real #s that is)
if (b2_4ac <= 0) return 0;
b2_4ac = sqrt(b2_4ac);
t1 = (-b - b2_4ac)/2*a,
t2 = (-b + b2_4ac)/2*a;
t1 = (-b - b2_4ac)/(2*a),
t2 = (-b + b2_4ac)/(2*a);
}

// calculate number of intersections
Expand Down

0 comments on commit 3f4a697

Please sign in to comment.