summaryrefslogtreecommitdiffstats
path: root/src/2geom/circle.h
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2015-05-22 08:23:27 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2015-05-22 08:23:27 +0000
commit25fa09178b7d0d0befa708e93ea5316ef381caa0 (patch)
tree550b4d0d66d0d234b3f49e868cb747987dcc6bf8 /src/2geom/circle.h
parentMerge from trunk (diff)
downloadinkscape-25fa09178b7d0d0befa708e93ea5316ef381caa0.tar.gz
inkscape-25fa09178b7d0d0befa708e93ea5316ef381caa0.zip
Update to 2Geom revision 2396
(bzr r14059.2.16)
Diffstat (limited to 'src/2geom/circle.h')
-rw-r--r--src/2geom/circle.h72
1 files changed, 55 insertions, 17 deletions
diff --git a/src/2geom/circle.h b/src/2geom/circle.h
index 3c2115b12..c42cb7f80 100644
--- a/src/2geom/circle.h
+++ b/src/2geom/circle.h
@@ -34,8 +34,10 @@
#ifndef LIB2GEOM_SEEN_CIRCLE_H
#define LIB2GEOM_SEEN_CIRCLE_H
-#include <2geom/point.h>
#include <2geom/forward.h>
+#include <2geom/intersection.h>
+#include <2geom/point.h>
+#include <2geom/rect.h>
#include <2geom/transforms.h>
namespace Geom {
@@ -45,10 +47,11 @@ class EllipticalArc;
/** @brief Set of all points at a fixed distance from the center
* @ingroup Shapes */
class Circle
- : MultipliableNoncommutative< Circle, Translate
+ : boost::equality_comparable1< Circle
+ , MultipliableNoncommutative< Circle, Translate
, MultipliableNoncommutative< Circle, Rotate
, MultipliableNoncommutative< Circle, Zoom
- > > >
+ > > > >
{
Point _center;
Coord _radius;
@@ -66,28 +69,51 @@ public:
setCoefficients(A, B, C, D);
}
- // build a circle by its implicit equation:
- // Ax^2 + Ay^2 + Bx + Cy + D = 0
- void setCoefficients(Coord A, Coord B, Coord C, Coord D);
-
- /** @brief Fit the circle to the passed points using the least squares method.
- * @param points Samples at the perimeter of the circle */
- void fit(std::vector<Point> const &points);
-
- EllipticalArc *
- arc(Point const& initial, Point const& inner, Point const& final,
- bool svg_compliant = true);
-
- D2<SBasis> toSBasis();
- void getPath(PathVector &path_out);
+ // Construct the unique circle passing through three points.
+ //Circle(Point const &a, Point const &b, Point const &c);
Point center() const { return _center; }
Coord center(Dim2 d) const { return _center[d]; }
Coord radius() const { return _radius; }
+ Coord area() const { return M_PI * _radius * _radius; }
void setCenter(Point const &p) { _center = p; }
void setRadius(Coord c) { _radius = c; }
+ Rect boundsFast() const;
+ Rect boundsExact() const { return boundsFast(); }
+
+ Point pointAt(Coord t) const;
+ Coord valueAt(Coord t, Dim2 d) const;
+ Coord timeAt(Point const &p) const;
+ Coord nearestTime(Point const &p) const;
+
+ bool contains(Point const &p) const { return distance(p, _center) <= _radius; }
+ bool contains(Rect const &other) const;
+ bool contains(Circle const &other) const;
+
+ bool intersects(Line const &l) const;
+ bool intersects(LineSegment const &l) const;
+ bool intersects(Circle const &other) const;
+
+ std::vector<ShapeIntersection> intersect(Line const &other) const;
+ std::vector<ShapeIntersection> intersect(LineSegment const &other) const;
+ std::vector<ShapeIntersection> intersect(Circle const &other) const;
+
+ // build a circle by its implicit equation:
+ // Ax^2 + Ay^2 + Bx + Cy + D = 0
+ void setCoefficients(Coord A, Coord B, Coord C, Coord D);
+ void coefficients(Coord &A, Coord &B, Coord &C, Coord &D) const;
+ std::vector<Coord> coefficients() const;
+
+ Zoom unitCircleTransform() const;
+ Zoom inverseUnitCircleTransform() const;
+
+ EllipticalArc *
+ arc(Point const& initial, Point const& inner, Point const& final) const;
+
+ D2<SBasis> toSBasis() const;
+
Circle &operator*=(Translate const &t) {
_center *= t;
return *this;
@@ -100,8 +126,20 @@ public:
_radius *= z.scale();
return *this;
}
+
+ bool operator==(Circle const &other) const;
+
+ /** @brief Fit the circle to the passed points using the least squares method.
+ * @param points Samples at the perimeter of the circle */
+ void fit(std::vector<Point> const &points);
};
+bool are_near(Circle const &a, Circle const &b, Coord eps=EPSILON);
+
+std::ostream &operator<<(std::ostream &out, Circle const &c);
+
+//bool are_near(Circle const &a, Circle const &b, Coord eps = EPSILON);
+
} // end namespace Geom
#endif // LIB2GEOM_SEEN_CIRCLE_H