From 6fc86543ecc0e43b0db34746c518eb692e3630e0 Mon Sep 17 00:00:00 2001 From: Valentina Zhuravska Date: Fri, 19 Feb 2016 11:43:46 +0200 Subject: [PATCH] Little fixes --HG-- branch : feature --- src/libs/vgeometry/vellipticalarc.cpp | 8 +++++--- src/test/ValentinaTest/tst_varc.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/libs/vgeometry/vellipticalarc.cpp b/src/libs/vgeometry/vellipticalarc.cpp index 50d53ee72..99d474342 100644 --- a/src/libs/vgeometry/vellipticalarc.cpp +++ b/src/libs/vgeometry/vellipticalarc.cpp @@ -125,13 +125,13 @@ VEllipticalArc::~VEllipticalArc() */ qreal VEllipticalArc::GetLength() const { - qreal length; + qreal length = 0; QPainterPath elArc; QVector points = GetPoints(); elArc.moveTo(points.at(0)); for (qint32 i = 1; i < points.count(); ++i) { - elArc.lineTo(points.at(i)); + elArc.lineTo(points.at(i)); } length = elArc.length(); @@ -344,7 +344,9 @@ void VEllipticalArc::FindF2(qreal length) //--------------------------------------------------------------------------------------------------------------------- qreal VEllipticalArc::MaxLength() const { - return M_PI*(d->radius1+d->radius2); + const qreal h = ((d->radius1-d->radius2)*(d->radius1-d->radius2))/((d->radius1+d->radius2)*(d->radius1+d->radius2)); + const qreal ellipseLength = M_PI*(d->radius1+d->radius2)*(1+3*h/(10+qSqrt(4-3*h))); + return ellipseLength; } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/test/ValentinaTest/tst_varc.cpp b/src/test/ValentinaTest/tst_varc.cpp index 2f56ae3cb..127d45022 100644 --- a/src/test/ValentinaTest/tst_varc.cpp +++ b/src/test/ValentinaTest/tst_varc.cpp @@ -190,19 +190,19 @@ void TST_VArc::TestGetPoints() } { - qreal gSquere = 0.0;// geometry squere + qreal gSquere = 0.0;// geometry square if (qFuzzyCompare(arc.AngleArc(), 360.0)) - {// circle squere + {// circle square gSquere = M_PI * radius * radius; } else - {// sector squere + {// sector square gSquere = (M_PI * radius * radius) / 360.0 * arc.AngleArc(); points.append(center.toQPointF()); } - // calculated squere + // calculated square const qreal cSquare = qAbs(VAbstractDetail::SumTrapezoids(points)/2.0); const qreal value = qAbs(gSquere - cSquare); const QString errorMsg =