On Fri, 6 May 2005, Peter Moulder wrote:
On Tue, May 03, 2005 at 01:17:41PM -0400, mental@...3... wrote:
Quoting Michael Forbes <miforbes@...734...>:
Since LaTeX only does quadratic is it possible for Inkscape to convert from cubic to quadratic since I am working on export?
This is an interesting mathematical problem; whatever implementation you write, there's a fair chance that someone else will redo it. Thus, to save time, I suggest you just concentrate on choosing the interface, and use a placeholder implementation, and draw people's attention (e.g. here in this thread) to where it is so others can improve it.
The interface should allow any number of quadratic segments to be returned per cubic segment, and should probably pass a strictly positive double saying how far the approximation and the cubic are allowed to differ from each other.
An example placeholder implementation to convert a cubic bezier curve with control points NR::Point const cubic[0..3] to a quadratic bezier curve with control points NR::Point quad[0..2] is:
/* Same endpoints. */ quad[0] = cubic[0]; quad[2] = cubic[3];
/* Yucky first implementation. Doesn't even maintain tangents. */ quad[1] = .5 * (cubic[1] + cubic[2]);
[Return something indicating that one quadratic segment was used.]
Commit such a function as soon as possible (and reply to this message saying where it is), and maybe someone else will already have improved it a little by the time you have the rest checked in.
pjrm.
For the moment, I am trying to get PSTricks to work. I am fairly new to Inkscape but I am fairly sure PSTricks is easier to implement considering the conversion issues for bezier curves among other things.
-Michael Forbes