From b0a9bcb9e1da6e5192cf37aedcd3b87a4041b911 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 23 Nov 2009 21:15:06 +0000 Subject: update 2geom. needed for extrude lpe (bzr r8840) --- src/2geom/d2.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/2geom/d2.h') 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 x = f[X].valueAndDerivatives(t, n), y = f[Y].valueAndDerivatives(t, n); // always returns a vector of size n+1 std::vector 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 const & a, D2 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 +inline T +dot(D2 const & a, Point const & b) { + boost::function_requires >(); + boost::function_requires >(); + + 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 inline T cross(D2 const & a, D2 const & b) { -- cgit v1.2.3