Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
revert order in lenghts. don't break the API
  • Loading branch information
lbartoletti committed Dec 6, 2021
1 parent 9246081 commit 1a14fb8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions src/core/geometry/qgstriangle.cpp
Expand Up @@ -373,9 +373,9 @@ QVector<double> QgsTriangle::lengths() const
if ( isEmpty() )
return lengths;

lengths.append( vertexAt( 0 ).distance( vertexAt( 1 ) ) ); // c = |AB|
lengths.append( vertexAt( 1 ).distance( vertexAt( 2 ) ) ); // a = |BC|
lengths.append( vertexAt( 0 ).distance( vertexAt( 2 ) ) ); // b = |AC|
lengths.append( vertexAt( 0 ).distance( vertexAt( 1 ) ) ); // c = |AB|

return lengths;
}
Expand All @@ -388,9 +388,9 @@ QVector<double> QgsTriangle::angles() const

QVector<double> l = lengths();

const double a = l[0];
const double b = l[1];
const double c = l[2];
const double a = l[1];
const double b = l[2];
const double c = l[0];

const double a2 = a * a;
const double b2 = b * b;
Expand Down Expand Up @@ -579,12 +579,12 @@ QgsPoint QgsTriangle::inscribedCenter() const
return QgsPoint();

const QVector<double> l = lengths();
const double x = ( l.at( 0 ) * vertexAt( 0 ).x() +
l.at( 1 ) * vertexAt( 1 ).x() +
l.at( 2 ) * vertexAt( 2 ).x() ) / perimeter();
const double y = ( l.at( 0 ) * vertexAt( 0 ).y() +
l.at( 1 ) * vertexAt( 1 ).y() +
l.at( 2 ) * vertexAt( 2 ).y() ) / perimeter();
const double x = ( l.at( 0 ) * vertexAt( 2 ).x() +
l.at( 1 ) * vertexAt( 0 ).x() +
l.at( 2 ) * vertexAt( 1 ).x() ) / perimeter();
const double y = ( l.at( 0 ) * vertexAt( 2 ).y() +
l.at( 1 ) * vertexAt( 0 ).y() +
l.at( 2 ) * vertexAt( 1 ).y() ) / perimeter();

QgsPoint center( x, y );

Expand Down
4 changes: 2 additions & 2 deletions tests/src/core/geometry/testqgstriangle.cpp
Expand Up @@ -818,7 +818,7 @@ void TestQgsTriangle::types()
tr = QgsTriangle( QgsPoint( 7.2825, 4.2368 ), QgsPoint( 13.0058, 3.3218 ),
QgsPoint( 9.2145, 6.5242 ) );
// angles in radians 58.8978;31.1036;89.9985
// length 4.96279;2.99413;5.79598
// length 5.79598;4.96279;2.99413
QVERIFY( !tr.isDegenerate() );
QVERIFY( tr.isRight() );
QVERIFY( !tr.isIsocele() );
Expand Down Expand Up @@ -913,8 +913,8 @@ void TestQgsTriangle::lengths()

QVector<double> l_tested, l_t7 = tr.lengths();
l_tested.append( 5 );
l_tested.append( std::sqrt( 5 * 5 + 5 * 5 ) );
l_tested.append( 5 );
l_tested.append( std::sqrt( 5 * 5 + 5 * 5 ) );

QGSCOMPARENEAR( l_tested.at( 0 ), l_t7.at( 0 ), 0.0001 );
QGSCOMPARENEAR( l_tested.at( 1 ), l_t7.at( 1 ), 0.0001 );
Expand Down

0 comments on commit 1a14fb8

Please sign in to comment.