From 6dd9187e01631f9496b6cea835382397cc770382 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 28 Apr 2014 20:58:32 +0200 Subject: partial 2geom update. linearize the measure of the size of an ellipse (LP Bug 1309225), by Alvin Penner Fixed bugs: - https://launchpad.net/bugs/1309225 (bzr r13320) --- src/2geom/ellipse.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/2geom') diff --git a/src/2geom/ellipse.cpp b/src/2geom/ellipse.cpp index bea99e5dd..2686844b2 100644 --- a/src/2geom/ellipse.cpp +++ b/src/2geom/ellipse.cpp @@ -36,6 +36,7 @@ #include <2geom/numeric/fitting-tool.h> #include <2geom/numeric/fitting-model.h> +using std::swap; namespace Geom { @@ -102,7 +103,7 @@ void Ellipse::set(double A, double B, double C, double D, double E, double F) // the solution is not unique so we choose always the ellipse // with a rotation angle between 0 and PI/2 - if ( swap_axes ) std::swap(rx, ry); + if ( swap_axes ) swap(rx, ry); if ( are_near(rot, M_PI/2) || are_near(rot, -M_PI/2) || are_near(rx, ry) ) @@ -233,7 +234,7 @@ Ellipse Ellipse::transformed(Affine const& m) const Point new_center = center() * m; Affine M = m.withoutTranslation(); Affine AM = A * M; - if ( are_near(AM.det(), 0) ) + if ( are_near(std::sqrt(fabs(AM.det())), 0) ) { double angle; if (AM[0] != 0) @@ -262,7 +263,7 @@ Ellipse Ellipse::transformed(Affine const& m) const Affine invm = M.inverse(); Q = invm * Q ; - std::swap( invm[1], invm[2] ); + swap( invm[1], invm[2] ); Q *= invm; Ellipse e(Q[0], 2*Q[1], Q[3], 0, 0, -1); e.m_centre = new_center; -- cgit v1.2.3