summaryrefslogtreecommitdiffstats
path: root/src/2geom/ellipse.cpp
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2015-07-04 15:25:59 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2015-07-04 15:25:59 +0000
commit60437ac397d41678daba5daece227240e8ddd364 (patch)
tree31f18c8296ffde9122492b46623375fc98585b17 /src/2geom/ellipse.cpp
parent2Geom CMake adjustment (diff)
downloadinkscape-60437ac397d41678daba5daece227240e8ddd364.tar.gz
inkscape-60437ac397d41678daba5daece227240e8ddd364.zip
Upgrade to 2Geom r2413
(bzr r14059.2.18)
Diffstat (limited to 'src/2geom/ellipse.cpp')
-rw-r--r--src/2geom/ellipse.cpp37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/2geom/ellipse.cpp b/src/2geom/ellipse.cpp
index 46c60d85d..0264ab4ae 100644
--- a/src/2geom/ellipse.cpp
+++ b/src/2geom/ellipse.cpp
@@ -97,6 +97,14 @@ void Ellipse::setCoefficients(double A, double B, double C, double D, double E,
makeCanonical();
}
+Point Ellipse::initialPoint() const
+{
+ Coord sinrot, cosrot;
+ sincos(_angle, sinrot, cosrot);
+ Point p(ray(X) * cosrot + center(X), ray(X) * sinrot + center(Y));
+ return p;
+}
+
Affine Ellipse::unitCircleTransform() const
{
@@ -299,8 +307,19 @@ Point Ellipse::pointAt(Coord t) const
Coord Ellipse::valueAt(Coord t, Dim2 d) const
{
- // TODO: more efficient version.
- return pointAt(t)[d];
+ Coord sinrot, cosrot, cost, sint;
+ sincos(rotationAngle(), sinrot, cosrot);
+ sincos(t, sint, cost);
+
+ if ( d == X ) {
+ return ray(X) * cosrot * cost
+ - ray(Y) * sinrot * sint
+ + center(X);
+ } else {
+ return ray(X) * sinrot * cost
+ + ray(Y) * cosrot * sint
+ + center(Y);
+ }
}
Coord Ellipse::timeAt(Point const &p) const
@@ -319,6 +338,20 @@ Coord Ellipse::timeAt(Point const &p) const
return Angle(atan2(p * iuct)).radians0(); // return a value in [0, 2pi)
}
+Point Ellipse::unitTangentAt(Coord t) const
+{
+ Point p = Point::polar(t + M_PI/2);
+ p *= unitCircleTransform().withoutTranslation();
+ p.normalize();
+ return p;
+}
+
+bool Ellipse::contains(Point const &p) const
+{
+ Point tp = p * inverseUnitCircleTransform();
+ return tp.length() <= 1;
+}
+
std::vector<ShapeIntersection> Ellipse::intersect(Line const &line) const
{