Including BSD-Licenced code in Inkscape

Hi,
TLDR: I want to include 3-clause BSD licenced code in Inkscape.
I want to improve curve fitting in Inkscape. I was told that Inkscape uses the GSL for root finding etc. so I thought I might implement curve fitting using the headers <gsl/gsl_multifit_nlinear.h>
This works but I'd like to improve it by providing derivatives to the solver instead of relying on numerical differentiation. I researched Autodiff tools and found that most require libraries which are difficult to build on windows. At work I use Ceres solver. I extracted the autodiff code (jet.h) from the source code and modified slightly so it works without futher dependencies.
Ceres is licenced under the 3-clause BSD licence: http://ceres-solver.org/license.html
May I include the modified source code in Inkscape?
Best Regards, Alexander

It seems to me that, from the license compatibility perspective that's ok.
I'm not sure, though, if bundling a derivative of a library is a good idea, since it can potentially be left without updates in sync with upstream in the long run.
Maybe your improvements to the library could be accepted upstream first?
2016-11-30 10:27 GMT-02:00 Alexander Brock <a.brock@...2965...>:
Hi,
TLDR: I want to include 3-clause BSD licenced code in Inkscape.
I want to improve curve fitting in Inkscape. I was told that Inkscape uses the GSL for root finding etc. so I thought I might implement curve fitting using the headers <gsl/gsl_multifit_nlinear.h>
This works but I'd like to improve it by providing derivatives to the solver instead of relying on numerical differentiation. I researched Autodiff tools and found that most require libraries which are difficult to build on windows. At work I use Ceres solver. I extracted the autodiff code (jet.h) from the source code and modified slightly so it works without futher dependencies.
Ceres is licenced under the 3-clause BSD licence: http://ceres-solver.org/license.html
May I include the modified source code in Inkscape?
Best Regards, Alexander
Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel

On 11/30/2016 01:41 PM, Felipe Sanches wrote:
It seems to me that, from the license compatibility perspective that's ok.
I'm not sure, though, if bundling a derivative of a library is a good idea, since it can potentially be left without updates in sync with upstream in the long run.
I could use the original file if I copy two more (very small) headers from ceres, this would mean that Inkscape depends on Eigen (a header-only library for linear algebra).
Making Inkscape depend on Ceres would make implementation of optimization more comfortable and make all that copying unnecessary but building on Windows seem complicated: http://ceres-solver.org/building.html#windows
Maybe your improvements to the library could be accepted upstream first?
Unlikely, I simply stripped the Eigen dependency and removed the ability to calculate higher-order derivatives. The file itself is a very simple file, most parts were written 2012/2013 according to git blame, it's essentially an implementation of a vector with very special rules for operations +-*/ and some functions like exp, tan etc.
Best Regards, Alexander

License wise (IANAL) the BSD-New license is compatible with the GPL2+/3+ we're currently using for Inkscape.
The code would then be distributed as GPL in the whole project.
Technical issues are the only ones that need discussion I think.
Best Regards, Martin Owens
On Wed, 2016-11-30 at 13:27 +0100, Alexander Brock wrote:
Hi,
TLDR: I want to include 3-clause BSD licenced code in Inkscape.
I want to improve curve fitting in Inkscape. I was told that Inkscape uses the GSL for root finding etc. so I thought I might implement curve fitting using the headers <gsl/gsl_multifit_nlinear.h>
This works but I'd like to improve it by providing derivatives to the solver instead of relying on numerical differentiation. I researched Autodiff tools and found that most require libraries which are difficult to build on windows. At work I use Ceres solver. I extracted the autodiff code (jet.h) from the source code and modified slightly so it works without futher dependencies.
Ceres is licenced under the 3-clause BSD licence: http://ceres-solver.org/license.html
May I include the modified source code in Inkscape?
Best Regards, Alexander
Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel

Hi,
I added a curve fitting algorithm to 2geom which takes a std::vector of Geom::Point and fits a Geom::CubicBezier to the points.
It fits (non-degenerate) cubic bezier curves to given points within half a millisecond up to an error of 1e-9.
You can find it here: https://github.com/abrock/lib2geom
In src/test/bezier-fit-test.cpp I made three simple tests, one "normal" curve and two (nearly) degenerate curves with (nearly) colinear points. I create a Cubic Bezier, select 20 points and give these to the fitting function (which doesn't know the original curve).
Results:
Normal Curve: Speed: 2678 curves per second Worst error: 1.31799e-10 at t=0.736842
Degenerate Curve: New method: 1567.89 curves per second Worst error: 6.84045e-09 at t=0.110945
Nearly degenerate curve: New method: 534.738 curves per second Worst error: 0.0284499 at t=0.0958247
in src/2geom/bezier-utils.cpp are the new functions:
- fit_bezier sets up the nonlinear least squares problem
Helper functions: - bezierfit_f calculates residuals - bezierfit_df calculates derivatives of residuals - bezier_distance helps calculating derivatives, it mainly contains a templated evaluation of Cubic Bezier functions.
src/2geom/jet.h contains the implementation of dual numbers I copied from the Ceres source code
Best Regards, Alexander

Hi Alexander,
Looks interesting.
As you are proposing this as an addition to lib2geom, the proper place to discuss this is on the lib2geom-devel list (lib2geom is a semi- independent project):
lib2geom-devel@lists.sourceforge.net
Tav
Hi,
I added a curve fitting algorithm to 2geom which takes a std::vector of Geom::Point and fits a Geom::CubicBezier to the points.
It fits (non-degenerate) cubic bezier curves to given points within half a millisecond up to an error of 1e-9.
You can find it here: https://github.com/abrock/lib2geom
In src/test/bezier-fit-test.cpp I made three simple tests, one "normal" curve and two (nearly) degenerate curves with (nearly) colinear points. I create a Cubic Bezier, select 20 points and give these to the fitting function (which doesn't know the original curve).
Results:
Normal Curve: Speed: 2678 curves per second Worst error: 1.31799e-10 at t=0.736842
Degenerate Curve: New method: 1567.89 curves per second Worst error: 6.84045e-09 at t=0.110945
Nearly degenerate curve: New method: 534.738 curves per second Worst error: 0.0284499 at t=0.0958247
in src/2geom/bezier-utils.cpp are the new functions:
- fit_bezier sets up the nonlinear least squares problem
Helper functions:
- bezierfit_f calculates residuals
- bezierfit_df calculates derivatives of residuals
- bezier_distance helps calculating derivatives, it mainly contains a
templated evaluation of Cubic Bezier functions.
src/2geom/jet.h contains the implementation of dual numbers I copied from the Ceres source code
Best Regards, Alexander
Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel

If we can just constrain the code licence to match the 2geom one, I think everything is fine, otherwise I guess we could include separate licencing for just this piece of code.
I'm happy to do a code review if you remind me in a few weeks.
njh
On Thu, Dec 01, 2016 at 07:52:06AM +0100, Tavmjong Bah wrote:
Hi Alexander,
Looks interesting.
As you are proposing this as an addition to lib2geom, the proper place to discuss this is on the lib2geom-devel list (lib2geom is a semi- independent project):
lib2geom-devel@lists.sourceforge.net
Tav
Hi,
I added a curve fitting algorithm to 2geom which takes a std::vector of Geom::Point and fits a Geom::CubicBezier to the points.
It fits (non-degenerate) cubic bezier curves to given points within half a millisecond up to an error of 1e-9.
You can find it here: https://github.com/abrock/lib2geom
In src/test/bezier-fit-test.cpp I made three simple tests, one "normal" curve and two (nearly) degenerate curves with (nearly) colinear points. I create a Cubic Bezier, select 20 points and give these to the fitting function (which doesn't know the original curve).
Results:
Normal Curve: Speed: 2678 curves per second Worst error: 1.31799e-10 at t=0.736842
Degenerate Curve: New method: 1567.89 curves per second Worst error: 6.84045e-09 at t=0.110945
Nearly degenerate curve: New method: 534.738 curves per second Worst error: 0.0284499 at t=0.0958247
in src/2geom/bezier-utils.cpp are the new functions:
- fit_bezier sets up the nonlinear least squares problem
Helper functions:
- bezierfit_f calculates residuals
- bezierfit_df calculates derivatives of residuals
- bezier_distance helps calculating derivatives, it mainly contains a
templated evaluation of Cubic Bezier functions.
src/2geom/jet.h contains the implementation of dual numbers I copied from the Ceres source code
Best Regards, Alexander
Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
Inkscape-devel mailing list Inkscape-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/inkscape-devel
participants (5)
-
Alexander Brock
-
Felipe Sanches
-
Martin Owens
-
Nathan Hurst
-
Tavmjong Bah