diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2012-04-13 21:42:28 +0000 |
|---|---|---|
| committer | Johan B. C. Engelen <j.b.c.engelen@alumnus.utwente.nl> | 2012-04-13 21:42:28 +0000 |
| commit | b307246cda3ad55e4a00b596de964a492196c0fa (patch) | |
| tree | 505c74b5a5635f539a0d971c7b417a77af211dd2 /src/2geom/d2-sbasis.cpp | |
| parent | probably this was intended (diff) | |
| download | inkscape-b307246cda3ad55e4a00b596de964a492196c0fa.tar.gz inkscape-b307246cda3ad55e4a00b596de964a492196c0fa.zip | |
small 2geom update
(bzr r11239)
Diffstat (limited to 'src/2geom/d2-sbasis.cpp')
| -rw-r--r-- | src/2geom/d2-sbasis.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/2geom/d2-sbasis.cpp b/src/2geom/d2-sbasis.cpp index 7bfb7c6c5..486ada9a2 100644 --- a/src/2geom/d2-sbasis.cpp +++ b/src/2geom/d2-sbasis.cpp @@ -185,6 +185,19 @@ split_at_discontinuities (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwsbi return ret; } +Point unitTangentAt(D2<SBasis> const & a, Coord t, unsigned n) +{ + std::vector<Point> derivs = a.valueAndDerivatives(t, n); + for (unsigned deriv_n = 1; deriv_n < derivs.size(); deriv_n++) { + Coord length = derivs[deriv_n].length(); + if ( ! are_near(length, 0) ) { + // length of derivative is non-zero, so return unit vector + return derivs[deriv_n] / length; + } + } + return Point (0,0); +} + static void set_first_point(Piecewise<D2<SBasis> > &f, Point a){ if ( f.empty() ){ f.concat(Piecewise<D2<SBasis> >(D2<SBasis>(Linear(a[X]),Linear(a[Y])))); |
