diff -r 17e0ba522478 src/core/pal/pointset.cpp --- a/src/core/pal/pointset.cpp Thu Mar 29 16:58:30 2012 +0300 +++ b/src/core/pal/pointset.cpp Thu Mar 29 17:06:29 2012 +0300 @@ -966,14 +966,14 @@ for ( i = 0; i < nbPoints; i++ ) { j = i + 1; if ( j == nbPoints ) j = 0; - tmp = ( x[i] * y[j] - x[j] * y[i] ); - cx += ( x[i] + x[j] ) * tmp; - cy += ( y[i] + y[j] ) * tmp; + tmp = ( ( x[i] - x[0] ) * ( y[j] - y[0] ) - ( x[j] - x[0] ) * ( y[i] - y[0] ) ); + cx += ( x[i] + x[j] - 2 * x[0] ) * tmp; + cy += ( y[i] + y[j] - 2 * y[0] ) * tmp; A += tmp; } - px = cx / ( 3 * A ); - py = cy / ( 3 * A ); + px = x[0] + cx / ( 3 * A ); + py = y[0] + cy / ( 3 * A ); } } // end namespace diff -r 17e0ba522478 src/core/qgscentralpointpositionmanager.cpp --- a/src/core/qgscentralpointpositionmanager.cpp Thu Mar 29 16:58:30 2012 +0300 +++ b/src/core/qgscentralpointpositionmanager.cpp Thu Mar 29 17:06:29 2012 +0300 @@ -232,17 +232,17 @@ for ( i = numberOfPoints - 1, j = 0; j < numberOfPoints; i = j, j++ ) { - ai = x[i] * y[j] - x[j] * y[i]; + ai = ( x[i] - x[0] ) * ( y[j] - y[0] ) - ( x[j] - x[0] ) * ( y[i] - y[0] ); atmp += ai; - xtmp += ( x[j] + x[i] ) * ai; - ytmp += ( y[j] + y[i] ) * ai; + xtmp += ( x[j] + x[i] - 2 * x[0] ) * ai; + ytmp += ( y[j] + y[i] - 2 * y[0] ) * ai; } if ( atmp == 0 ) { return 2; } - centroidX = xtmp / ( 3 * atmp ); - centroidY = ytmp / ( 3 * atmp ); + centroidX = x[0] + xtmp / ( 3 * atmp ); + centroidY = y[0] + ytmp / ( 3 * atmp ); return 0; }