Code

update 2geom. needed for extrude lpe
[inkscape.git] / src / 2geom / d2.h
index 547d8c658717e136c6724ec7bace77ce0bda27a0..b2a0f886694ef36658efbffa1e5e98bada92b87e 100644 (file)
@@ -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) {