En caso de duda, compruebe el código la respuesta parece ser que sólo se utilizan en el cálculo los puntos del casco convexo y todos esos puntos se consideran a su vez:
QgsGeometry QgsInternalGeometryEngine::orientedMinimumBoundingBox( double &area, double &angle, double &width, double &height ) const
{
mLastError.clear();
QgsRectangle minRect;
area = std::numeric_limits<double>::max();
angle = 0;
width = std::numeric_limits<double>::max();
height = std::numeric_limits<double>::max();
if ( !mGeometry || mGeometry->nCoordinates() < 2 )
return QgsGeometry();
std::unique_ptr< QgsGeometryEngine >engine( QgsGeometry::createGeometryEngine( mGeometry ) );
QString error;
std::unique_ptr< QgsAbstractGeometry > hull( engine->convexHull( &mLastError ) );
if ( !hull )
return QgsGeometry();
QgsVertexId vertexId;
QgsPoint pt0;
QgsPoint pt1;
QgsPoint pt2;
// get first point
hull->nextVertex( vertexId, pt0 );
pt1 = pt0;
double totalRotation = 0;
while ( hull->nextVertex( vertexId, pt2 ) )
{
double currentAngle = QgsGeometryUtils::lineAngle( pt1.x(), pt1.y(), pt2.x(), pt2.y() );
double rotateAngle = 180.0 / M_PI * currentAngle;
totalRotation += rotateAngle;
QTransform t = QTransform::fromTranslate( pt0.x(), pt0.y() );
t.rotate( rotateAngle );
t.translate( -pt0.x(), -pt0.y() );
hull->transform( t );
QgsRectangle bounds = hull->boundingBox();
double currentArea = bounds.width() * bounds.height();
if ( currentArea < area )
{
minRect = bounds;
area = currentArea;
angle = totalRotation;
width = bounds.width();
height = bounds.height();
}
pt1 = hull->vertexAt( vertexId );
}
// constrain angle to 0 - 180
if ( angle > 180.0 )
angle = std::fmod( angle, 180.0 );
return minBounds;
}
// constrain angle to 0 - 180
if ( angle > 180.0 )
angle = std::fmod( angle, 180.0 );
return minBounds;
}
0 votos
Tu segunda frase no tiene mucho sentido. ¿Podría editar su pregunta para aclararla?