I got that cool app idea... It wouldn't have many customer, but it would have some and, to really shine, I just needed to solve one tiny (ahem) mathematical problems... Plus it would be like my.. mmm.. legacy? you know something, forgot the word, that shows your art and pride!
3 years and many frustration later (to be fair I spent more time playing video game than looking at it, since it's trauma inducing frustration) it isn't complete..
At this stage the code looks almost simple and elegant (some method implementation are still scary though, some of them are 300 lines!) but it finally stumbled on what I guess looks strongly like... unavoidable mathematical rounding error...
It all starts with Bezier-Bezier curve intersection is an inexact science...
And it shows in unexpected place (or maybe dreadly expected hey?) when one does potato-potato intersections...
I don't want to give up.. but I have doubts..
An idea just hit me...
What if I made an article "a potato-potato intersection algorithm that almost work", would that attract the attention of challenge seeking programmer?
I would have to share sh*t ton of (undocumented) visualization code though (I dunno how much of my utility library I need to make it work, but just the low level visual classes are 100KB and 12 files)
And it's also part of what make my (unfinished) app looks great... Mmmm...
Or I could share the unit test code... but it's dreadfull and not conducive to creativity, it looks like that:
(data was collected from a user friendly test app)
[Fact]
public void ToughCut()
{
var cutter = new Ring(new Element(new Point(130.783333333333, 199.310477598184)), new Element(new Point(127.38497431913, 199.310477598184), new Point(124.073849393798, 198.234627893256), new Point(121.32451919832, 196.237122582712)), new Element(new Point(118.575189002842, 194.239617272168), new Point(116.528801257989, 191.423006177879), new Point(115.478650569613, 188.190974692711)), new Element(new Point(114.428499881237, 184.958943207542), new Point(114.428499881237, 181.477420428821), new Point(115.478650569613, 178.245388943653)), new Element(new Point(116.528801257989, 175.013357458484), new Point(118.575189002842, 172.196746364196), new Point(121.32451919832, 170.199241053652)), new Element(new Point(124.073849393798, 168.201735743108), new Point(127.38497431913, 167.12588603818), new Point(130.783333333333, 167.12588603818)), new Element(new Point(131.219696969697, 167.12588603818)), new Element(new Point(134.6180559839, 167.12588603818), new Point(137.929180909233, 168.201735743108), new Point(140.678511104711, 170.199241053652)), new Element(new Point(143.427841300188, 172.196746364196), new Point(145.474229045041, 175.013357458484), new Point(146.524379733417, 178.245388943653)), new Element(new Point(147.574530421793, 181.477420428821), new Point(147.574530421793, 184.958943207542), new Point(146.524379733417, 188.190974692711)), new Element(new Point(145.474229045041, 191.423006177879), new Point(143.427841300188, 194.239617272168), new Point(140.678511104711, 196.237122582712)), new Element(new Point(137.929180909233, 198.234627893256), new Point(134.6180559839, 199.310477598184), new Point(131.219696969697, 199.310477598184)));
var shape = new Shape(new Ring(new Element(new Point(12.7754813116188, -33.4128419451628), new Point(19.5223174580931, -29.9751572249652)), new Element(new Point(179.975157224965, 130.477682541907), new Point(183.412841945163, 137.224518688381)), new Element(new Point(185.725341896497, 151.825068758803), new Point(184.540796469908, 159.303994240127)), new Element(new Point(177.829660223277, 172.475340741641), new Point(172.475340741641, 177.829660223277)), new Element(new Point(159.303994240127, 184.540796469908), new Point(151.825068758803, 185.725341896497)), new Element(new Point(147.413657866616, 184.927395588484)), new Element(new Point(146.852379570287, 182.353400030402)), new Element(new Point(146.522877591701, 179.583755006682)), new Element(new Point(145.383023854803, 176.075645925844), new Point(144.229050444769, 174.093123340167)), new Element(new Point(141.746213714654, 171.399140511575)), new Element(new Point(139.217451805972, 169.454756076673), new Point(138.114716791943, 168.838299011114)), new Element(new Point(136.430867679513, 168.027334481522)), new Element(new Point(133.339495787831, 167.287179375534)), new Element(new Point(131.869596806395, 167.12588603818)), new Element(new Point(126.328777433712, 167.1807243084), new Point(125.140927792807, 167.390174249117)), new Element(new Point(120.57800049798, 170.108706697922)), new Element(new Point(-30.046677867818, 19.3819502930698), new Point(-33.4128419451628, 12.7754813116189)), new Element(new Point(-35.7253418964969, -1.82506875880269), new Point(-34.5407964699084, -9.30399424012683)), new Element(new Point(-27.8296602232773, -22.4753407416414), new Point(-22.4753407416414, -27.8296602232773)), new Element(new Point(-9.30399424012684, -34.5407964699084), new Point(-1.8250687588027, -35.7253418964969), new Point(5.47520627640808, -34.5690919208298))));
var result = shape.Cut(cutter, 0.1);
Assert.Single(result.Shapes);
}
|