User talk:Petelomax: Difference between revisions

No edit summary
Line 267:
==I wrote a Phix==
I wrote a second implementation of [[Bézier_curves/Intersections]] in Phix. It uses "unique" in a way I think will function correctly enough but about which it will do no harm if you come up with a more "fuzzy" alternative. :) (I’m thinking of writing a Scheme implementation that does essentially what the "unique" does but does it by making endpoint checks a separate matter. [If two floating point numbers are equal, for instance because copied from the same source, they are equal, no matter what talking heads say!] Also adding an absolute tolerance besides the flatness tolerance. And then moving on to Bézier clipping, because I’ve never completed an implementation of intersections using that. Or implementing my algorithm but for cubics, as a side project.) --[[User:Chemoelectric|Chemoelectric]] ([[User talk:Chemoelectric|talk]]) 11:38, 12 June 2023 (UTC)
:Yes, unique() only eliminates binary-exact [nested/all] floats, so I'd just write any such "fuzzy" filtering like this:
sequence t_pairs = unique (find_intersections (p, q, flatness_tolerance))
for i=length(tpairs) to 2 by -1 do
if fuzzy(tpairs[i],tpairs[i-1]) then t_pairs[i..i] = {} end if
end for
:<small>(Obviously the "by -1" ensures that deleting t_pairs[i] does not mess up any subsequent indexing.)</small><br>
:Note there may also be some cases where the natural sort order (on which unique is based) is not good enough, such as {{0.51,0.71}, {0.515,800}, {0.52,0.71}} where the first and last are "fuzzy-same" but the middle one clearly ain't. Rounding things before throwing them at unique() might perhaps prove better, or a full inner "j=i-1 to 1 by -1" might be needed. --[[User:Petelomax|Petelomax]] ([[User talk:Petelomax|talk]]) 16:41, 12 June 2023 (UTC)
7,806

edits