
On 11/04/13 02:11, Alexander Brock wrote:
I also formulated a target function for minimizing the distance between two curves and calculated the partial derivatives of this function. I'm pretty confident I will be able to use a gradient based method for finding the two control points which lead to minimal distance between the original curve and the new one.
I have implemented a simple gradient based method and I'm very pleased with (most of) the results. I have discovered a few problems and I have questions:
1. The original fitting method fits the curve to a set of points obtained by taking 10 samples from each segment. This is a problem if the segments have very different lengths, the influence of very small parts of the original shape is way too big. I could handle this by multiplying each term by the length of the corresponding segment but I think it's better to get a set of evenly distributed points in the first place.
See Path 1 in the attached svg file for an example of a bad fit due to different segment lengths
2. In most tests the method stops at some point because no improvement occurs no matter how small the step size is chosen allthough the fit isn't perfect yet. See path 2/3 for examples. Currently the algorithm just stops but I'd like to continue somehow. I could choose a random search direction and try to find a better solution or maybe just take random samples from a small neighbourhood of the current set of parameters.
3. make -j3 takes > 2m to finish even when I only change one line in bezier-utils.cpp on a Core2Duo, 2,4GHz, is that normal? make install then takes >1m. I use ccache, g++ and turned optimization off.
4. Where can I find examples for automated tests?
5. I Attached the result of bzr diff >> path-optimization.patch for those interested in playing with the code. I don't think it's suitable for production yet.
Alexander