1 #ifndef _SBASIS_GEOMETRIC
2 #define _SBASIS_GEOMETRIC
3 #include <2geom/d2.h>
4 #include <2geom/piecewise.h>
5 #include <vector>
7 /**
8 * \file
9 * \brief two-dimensional geometric operators.
10 *
11 * Copyright 2007, JFBarraud
12 * Copyright 2007, njh
13 *
14 * These operators are built on a more 'polynomially robust'
15 * transformation to map a function that takes a [0,1] parameter to a
16 * 2d vector into a function that takes the same [0,1] parameter to a
17 * unit vector with the same direction.
18 *
19 * Rather that using (X/sqrt(X))(t) which involves two unstable
20 * operations, sqrt and divide, this approach forms a curve directly
21 * from the various tangent directions at each end (angular jet). As
22 * a result, the final path has a convergence behaviour derived from
23 * that of the sin and cos series. -- njh
24 */
26 namespace Geom{
28 Piecewise<D2<SBasis> >
29 cutAtRoots(Piecewise<D2<SBasis> > const &M, double tol=1e-4);
31 Piecewise<SBasis>
32 atan2(D2<SBasis> const &vect,
33 double tol=.01, unsigned order=3);
35 Piecewise<SBasis>
36 atan2(Piecewise<D2<SBasis> >const &vect,
37 double tol=.01, unsigned order=3);
39 D2<Piecewise<SBasis> >
40 tan2(SBasis const &angle,
41 double tol=.01, unsigned order=3);
43 D2<Piecewise<SBasis> >
44 tan2(Piecewise<SBasis> const &angle,
45 double tol=.01, unsigned order=3);
47 Piecewise<D2<SBasis> >
48 unitVector(D2<SBasis> const &vect,
49 double tol=.01, unsigned order=3);
50 Piecewise<D2<SBasis> >
51 unitVector(Piecewise<D2<SBasis> > const &vect,
52 double tol=.01, unsigned order=3);
54 // Piecewise<D2<SBasis> >
55 // uniform_speed(D2<SBasis> const M,
56 // double tol=.1);
58 Piecewise<SBasis> curvature( D2<SBasis> const &M, double tol=.01);
59 Piecewise<SBasis> curvature(Piecewise<D2<SBasis> > const &M, double tol=.01);
61 Piecewise<SBasis> arcLengthSb( D2<SBasis> const &M, double tol=.01);
62 Piecewise<SBasis> arcLengthSb(Piecewise<D2<SBasis> > const &M, double tol=.01);
64 double length( D2<SBasis> const &M, double tol=.01);
65 double length(Piecewise<D2<SBasis> > const &M, double tol=.01);
67 void length_integrating(D2<SBasis> const &B, double &result, double &abs_error, double tol);
69 Piecewise<D2<SBasis> >
70 arc_length_parametrization(D2<SBasis> const &M,
71 unsigned order=3,
72 double tol=.01);
73 Piecewise<D2<SBasis> >
74 arc_length_parametrization(Piecewise<D2<SBasis> > const &M,
75 unsigned order=3,
76 double tol=.01);
79 unsigned centroid(Piecewise<D2<SBasis> > const &p, Point& centroid, double &area);
81 std::vector<D2<SBasis> >
82 cubics_fitting_curvature(Point const &M0, Point const &M1,
83 Point const &dM0, Point const &dM1,
84 double d2M0xdM0, double d2M1xdM1,
85 int insist_on_speed_signs = 1,
86 double epsilon = 1e-5);
88 std::vector<D2<SBasis> >
89 cubics_fitting_curvature(Point const &M0, Point const &M1,
90 Point const &dM0, Point const &dM1,
91 Point const &d2M0, Point const &d2M1,
92 int insist_on_speed_signs = 1,
93 double epsilon = 1e-5);
95 std::vector<D2<SBasis> >
96 cubics_with_prescribed_curvature(Point const &M0, Point const &M1,
97 Point const &dM0, Point const &dM1,
98 double k0, double k1,
99 int insist_on_speed_signs = 1,
100 double error = 1e-5);
102 };
104 #endif
106 /*
107 Local Variables:
108 mode:c++
109 c-file-style:"stroustrup"
110 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
111 indent-tabs-mode:nil
112 fill-column:99
113 End:
114 */
115 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :