summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2a48800)
raw | patch | inline | side by side (parent: 2a48800)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 2 Dec 2007 23:14:54 +0000 (23:14 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 2 Dec 2007 23:14:54 +0000 (23:14 +0000) |
src/nodepath.cpp | patch | blob | history | |
src/sp-shape.cpp | patch | blob | history | |
src/util/Makefile_insert | patch | blob | history | |
src/util/mathfns.h | [new file with mode: 0644] | patch | blob |
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index f48a83b4f254e9e7e73b046c5338959494b66b53..1239f961bc2f399f149b650b34f36bb5852dc4cd 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
#include <algorithm>
#include "live_effects/lpeobject.h"
#include "live_effects/parameter/parameter.h"
+#include "util/mathfns.h"
class NR::Matrix;
@@ -4046,15 +4047,6 @@ static void sp_nodepath_subpath_open(Inkscape::NodePath::SubPath *sp,Inkscape::N
new_path->p.other = NULL;
}
-/**
- * Returns area in triangle given by points; may be negative.
- */
-inline double
-triangle_area (NR::Point p1, NR::Point p2, NR::Point p3)
-{
- return (p1[NR::X]*p2[NR::Y] + p1[NR::Y]*p3[NR::X] + p2[NR::X]*p3[NR::Y] - p2[NR::Y]*p3[NR::X] - p1[NR::Y]*p2[NR::X] - p1[NR::X]*p3[NR::Y]);
-}
-
/**
* Return new node in subpath with given properties.
* \param pos Position of node.
@@ -4079,7 +4071,7 @@ sp_nodepath_node_new(Inkscape::NodePath::SubPath *sp, Inkscape::NodePath::Node *
// use the type from sodipodi:nodetypes
n->type = type;
} else {
- if (fabs (triangle_area (*pos, *ppos, *npos)) < 1e-2) {
+ if (fabs (Inkscape::Util::triangle_area (*pos, *ppos, *npos)) < 1e-2) {
// points are (almost) collinear
if (NR::L2(*pos - *ppos) < 1e-6 || NR::L2(*pos - *npos) < 1e-6) {
// endnode, or a node with a retracted handle
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index 99b4977b9626cafe12846461490b8b6902452baf..a0c2249c7dd8d43100d35c0afe6d5cb73b5d4b47 100644 (file)
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
#include "bad-uri-exception.h"
#include "xml/repr.h"
-#include "nodepath.cpp" // for triangle_area()
+#include "util/mathfns.h" // for triangle_area()
#define noSHAPE_VERBOSE
// Determine whether a node is at a smooth part of the path, by
// calculating a measure for the collinearity of the handles
- bool c1 = fabs (triangle_area (pos, ppos, npos)) < 1; // points are (almost) collinear
+ bool c1 = fabs (Inkscape::Util::triangle_area (pos, ppos, npos)) < 1; // points are (almost) collinear
bool c2 = NR::L2(pos - ppos) < 1e-6 || NR::L2(pos - npos) < 1e-6; // endnode, or a node with a retracted handle
if (!(c1 & !c2)) {
*p = pos; // only return non-smooth nodes ("cusps")
index 41d3b9fb44d3a92b0671472e8bc749aae3cbad7e..913dda26b57c138d86cb39bdb08a7d4375d67c35 100644 (file)
--- a/src/util/Makefile_insert
+++ b/src/util/Makefile_insert
util/list.h \
util/list-container.h \
util/map-list.h \
+ util/mathfns.h \
util/reverse-list.h \
util/share.h \
util/share.cpp \
diff --git a/src/util/mathfns.h b/src/util/mathfns.h
--- /dev/null
+++ b/src/util/mathfns.h
@@ -0,0 +1,43 @@
+/*
+ * Inkscape::Util::... some mathmatical functions
+ *
+ * Authors:
+ * Johan Engelen <goejendaagh@zonnet.nl>
+ *
+ * Copyright (C) 2007 Johan Engelen
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifndef SEEN_INKSCAPE_UTIL_MATHFNS_H
+#define SEEN_INKSCAPE_UTIL_MATHFNS_H
+
+
+namespace Inkscape {
+
+namespace Util {
+
+/**
+ * Returns area in triangle given by points; may be negative.
+ */
+inline double
+triangle_area (NR::Point p1, NR::Point p2, NR::Point p3)
+{
+ return (p1[NR::X]*p2[NR::Y] + p1[NR::Y]*p3[NR::X] + p2[NR::X]*p3[NR::Y] - p2[NR::Y]*p3[NR::X] - p1[NR::Y]*p2[NR::X] - p1[NR::X]*p3[NR::Y]);
+}
+
+}
+
+}
+
+#endif
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :