Little fixes

--HG--
branch : feature
This commit is contained in:
Valentina Zhuravska 2016-02-19 11:43:46 +02:00
parent 37eb0e9e21
commit 6fc86543ec
2 changed files with 9 additions and 7 deletions

View File

@ -125,7 +125,7 @@ VEllipticalArc::~VEllipticalArc()
*/ */
qreal VEllipticalArc::GetLength() const qreal VEllipticalArc::GetLength() const
{ {
qreal length; qreal length = 0;
QPainterPath elArc; QPainterPath elArc;
QVector<QPointF> points = GetPoints(); QVector<QPointF> points = GetPoints();
elArc.moveTo(points.at(0)); elArc.moveTo(points.at(0));
@ -344,7 +344,9 @@ void VEllipticalArc::FindF2(qreal length)
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
qreal VEllipticalArc::MaxLength() const 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;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -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)) if (qFuzzyCompare(arc.AngleArc(), 360.0))
{// circle squere {// circle square
gSquere = M_PI * radius * radius; gSquere = M_PI * radius * radius;
} }
else else
{// sector squere {// sector square
gSquere = (M_PI * radius * radius) / 360.0 * arc.AngleArc(); gSquere = (M_PI * radius * radius) / 360.0 * arc.AngleArc();
points.append(center.toQPointF()); points.append(center.toQPointF());
} }
// calculated squere // calculated square
const qreal cSquare = qAbs(VAbstractDetail::SumTrapezoids(points)/2.0); const qreal cSquare = qAbs(VAbstractDetail::SumTrapezoids(points)/2.0);
const qreal value = qAbs(gSquere - cSquare); const qreal value = qAbs(gSquere - cSquare);
const QString errorMsg = const QString errorMsg =