Bézier curves/Intersections: Difference between revisions
Content added Content deleted
(→{{header|Phix}}: A second Phix implementation) |
m (→A Phix implementation of the "rectangle-pruned curve-flattening algorithm": Renamed a thing.) |
||
Line 3,155: | Line 3,155: | ||
end function |
end function |
||
function |
function segment_parameters (sequence a0, a1, b0, b1) |
||
-- Return the respective [0,1] parameters of line segments (a0,a1) |
-- Return the respective [0,1] parameters of line segments (a0,a1) |
||
-- and (b0,b1), for their intersection point. If there are not two |
-- and (b0,b1), for their intersection point. If there are not two |
||
Line 3,212: | Line 3,212: | ||
if flat_enough (qportion, tol) then |
if flat_enough (qportion, tol) then |
||
atom tp, tq |
atom tp, tq |
||
{tp, tq} = |
{tp, tq} = segment_parameters (pportion[ENDPT0], |
||
pportion[ENDPT1], |
pportion[ENDPT1], |
||
qportion[ENDPT0], |
qportion[ENDPT0], |
||
qportion[ENDPT1]) |
qportion[ENDPT1]) |
||
if 0 <= tp then |
if 0 <= tp then |
||
tp = (1 - tp) * pportion[T0] + tp * pportion[T1] |
tp = (1 - tp) * pportion[T0] + tp * pportion[T1] |