From: Nathan H. <nj...@nj...> - 2015-04-26 04:10:47
|
On Mon, Apr 20, 2015 at 02:18:36PM +0200, Krzysztof Kosiński wrote: > 2015-04-20 7:15 GMT+02:00 Nathan Hurst <nj...@nj...>: > >> - Linear and Bezier segments of arbitrary degree > >> - Code is fairly clean and understandable > >> - Reasonably good performance, even though there are very few > >> optimizations > > > > This is almost certainly an improvement on what we have, to gain > > confidence can you also write some unit tests that capture the various > > edge cases as per that svg (and anything else you can think of). > > The results will be slightly different than in that SVG, because the > algorithm I used does not require uncrossing as a preprocessing step. > I think this is a nice feature, since it preserves self-intersections > in places where they don't affect the result. I wrote a short summary > of the underlying algorithm on Wikipedia recently: > https://en.wikipedia.org/wiki/Greiner%E2%80%93Hormann_clipping_algorithm Nice! > For the arc-Bezier case, my thesis advisor suggested to convert > elliptical arcs to four rational quadratic Beziers, each representing > 1/4 of the ellipse between its conjugate diameters and intersect that > using well known algorithms, then go back to the elliptical arc > representation by using the fact that the weight of the middle control > point is related to the time on the elliptical arc (the angle in the > untransformed unit circle). I'm not sure about this. I'll first try > the conic equation route, since it's the simplest and requires minimal > new code. Yeah, I think that is wise. I'd forgotten about rational beziers representing conics. > The conic code implements some interesting stuff that I could use, but > it needs to be refactored first. I'm pretty certain that If I hadn't > spent substantial time on refactoring, writing unit tests for existing > stuff and fixing the uncovered bugs, I wouldn't have managed to get > this far. Yes, this work has desperately need to be done. I didn't grok the value of unit tests when I wrote the initial code. Now I do. Please refactor and unit test, it will make the library so much more trustworthy. njh |