diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2009-11-23 21:15:06 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2009-11-23 21:15:06 +0000 |
| commit | b0a9bcb9e1da6e5192cf37aedcd3b87a4041b911 (patch) | |
| tree | b302be68624c043cb13d55f9f17d0eb993cf1acb /src/2geom/d2.h | |
| parent | work on the lpe group undo bug. it's not solved, but i think LPE code does ev... (diff) | |
| download | inkscape-b0a9bcb9e1da6e5192cf37aedcd3b87a4041b911.tar.gz inkscape-b0a9bcb9e1da6e5192cf37aedcd3b87a4041b911.zip | |
update 2geom. needed for extrude lpe
(bzr r8840)
Diffstat (limited to 'src/2geom/d2.h')
| -rw-r--r-- | src/2geom/d2.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/2geom/d2.h b/src/2geom/d2.h index 547d8c658..b2a0f8866 100644 --- a/src/2geom/d2.h +++ b/src/2geom/d2.h @@ -99,7 +99,7 @@ class D2{ std::vector<Coord> x = f[X].valueAndDerivatives(t, n), y = f[Y].valueAndDerivatives(t, n); // always returns a vector of size n+1 std::vector<Point> res(n+1); - for (unsigned i = 0; i <= n; i++) { + for(unsigned i = 0; i <= n; i++) { res[i] = Point(x[i], y[i]); } return res; @@ -321,6 +321,25 @@ dot(D2<T> const & a, D2<T> const & b) { return r; } +/** @brief Calculates the 'dot product' or 'inner product' of \c a and \c b + * @return \f$a \bullet b = a_X b_X + a_Y b_Y\f$. + * @relates D2 */ +template <typename T> +inline T +dot(D2<T> const & a, Point const & b) { + boost::function_requires<AddableConcept<T> >(); + boost::function_requires<ScalableConcept<T> >(); + + T r; + for(unsigned i = 0; i < 2; i++) { + r += a[i] * b[i]; + } + return r; +} + +/** @brief Calculates the 'cross product' or 'outer product' of \c a and \c b + * @return \f$a \times b = a_Y b_X - a_X b_Y\f$. + * @relates D2 */ template <typename T> inline T cross(D2<T> const & a, D2<T> const & b) { |
