Bézier curves/Intersections: Difference between revisions

Content added Content deleted
(→‎{{header|Phix}}: A second Phix implementation)
Line 3,155: Line 3,155:
end function
end function


function segmentparameters (sequence a0, a1, b0, b1)
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} = segmentparameters (pportion[ENDPT0],
{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]