summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2012-03-04 20:14:33 +0000
committerJohan B. C. Engelen <j.b.c.engelen@alumnus.utwente.nl>2012-03-04 20:14:33 +0000
commit2cdb2f9439129fba16728110ac50633065dfa9ca (patch)
treed19e0d2ab6a2101260e9adcf0a94254b2313e5f6 /src
parentCmake build fix (diff)
downloadinkscape-2cdb2f9439129fba16728110ac50633065dfa9ca.tar.gz
inkscape-2cdb2f9439129fba16728110ac50633065dfa9ca.zip
2geom: isConstant and isZero should check a finite neighbourhood around zero.
(bzr r11045)
Diffstat (limited to 'src')
-rw-r--r--src/2geom/bezier.h8
-rw-r--r--src/2geom/d2.h8
-rw-r--r--src/2geom/linear.h4
-rw-r--r--src/2geom/sbasis.h10
4 files changed, 15 insertions, 15 deletions
diff --git a/src/2geom/bezier.h b/src/2geom/bezier.h
index 1e1b88587..176128328 100644
--- a/src/2geom/bezier.h
+++ b/src/2geom/bezier.h
@@ -193,15 +193,15 @@ public:
//IMPL: FragmentConcept
typedef Coord output_type;
- inline bool isZero() const {
+ inline bool isZero(double eps=EPSILON) const {
for(unsigned i = 0; i <= order(); i++) {
- if(c_[i] != 0) return false;
+ if( ! are_near(c_[i], 0., eps) ) return false;
}
return true;
}
- inline bool isConstant() const {
+ inline bool isConstant(double eps=EPSILON) const {
for(unsigned i = 1; i <= order(); i++) {
- if(c_[i] != c_[0]) return false;
+ if( ! are_near(c_[i], c_[0], eps) ) return false;
}
return true;
}
diff --git a/src/2geom/d2.h b/src/2geom/d2.h
index 4a4f45a63..ef88b2d68 100644
--- a/src/2geom/d2.h
+++ b/src/2geom/d2.h
@@ -72,13 +72,13 @@ class D2{
//IMPL: FragmentConcept
typedef Point output_type;
- bool isZero() const {
+ bool isZero(double eps=EPSILON) const {
boost::function_requires<FragmentConcept<T> >();
- return f[X].isZero() && f[Y].isZero();
+ return f[X].isZero(eps) && f[Y].isZero(eps);
}
- bool isConstant() const {
+ bool isConstant(double eps=EPSILON) const {
boost::function_requires<FragmentConcept<T> >();
- return f[X].isConstant() && f[Y].isConstant();
+ return f[X].isConstant(eps) && f[Y].isConstant(eps);
}
bool isFinite() const {
boost::function_requires<FragmentConcept<T> >();
diff --git a/src/2geom/linear.h b/src/2geom/linear.h
index df6dd9904..6e5132e12 100644
--- a/src/2geom/linear.h
+++ b/src/2geom/linear.h
@@ -72,8 +72,8 @@ public:
//IMPL: FragmentConcept
typedef double output_type;
- inline bool isZero() const { return a[0] == 0 && a[1] == 0; }
- inline bool isConstant() const { return a[0] == a[1]; }
+ inline bool isZero(double eps=EPSILON) const { return are_near(a[0], 0., eps) && are_near(a[1], 0., eps); }
+ inline bool isConstant(double eps=EPSILON) const { return are_near(a[0], a[1], eps); }
inline bool isFinite() const { return IS_FINITE(a[0]) && IS_FINITE(a[1]); }
inline double at0() const { return a[0]; }
diff --git a/src/2geom/sbasis.h b/src/2geom/sbasis.h
index dd2df55b9..e201f16ec 100644
--- a/src/2geom/sbasis.h
+++ b/src/2geom/sbasis.h
@@ -122,18 +122,18 @@ public:
//IMPL: FragmentConcept
typedef double output_type;
- inline bool isZero() const {
+ inline bool isZero(double eps=EPSILON) const {
if(empty()) return true;
for(unsigned i = 0; i < size(); i++) {
- if(!(*this)[i].isZero()) return false;
+ if(!(*this)[i].isZero(eps)) return false;
}
return true;
}
- inline bool isConstant() const {
+ inline bool isConstant(double eps=EPSILON) const {
if (empty()) return true;
- if(!(*this)[0].isConstant()) return false;
+ if(!(*this)[0].isConstant(eps)) return false;
for (unsigned i = 1; i < size(); i++) {
- if(!(*this)[i].isZero()) return false;
+ if(!(*this)[i].isZero(eps)) return false;
}
return true;
}