Is there a metric for computing the "scale" between two polygons?

1 visualización (últimos 30 días)
Dominik Mattioli
Dominik Mattioli el 27 de Ag. de 2020
Respondida: Bruno Luong el 27 de Ag. de 2020
I have two similarly shaped polygons, one of which has a smaller area, and both are centered about the same reference point. Is there a metric for describing or an algorithm for computing the scale between these two polygons? I would like to take the larger polygon and automatically scale it down to the smaller one.
Example: An octogon PG, with a hexagon sPG inside of it. Both are centered about (0,0). How do I automatically create a new polygon from PG that is roughly fitting sPG?
xOct = [2.922, 1.21, -1.21, -2.922, -2.922, -1.21, 1.21, 2.922];
yOct = [1.21, 2.922, 2.922, 1.21, -1.21, -2.922, -2.922, -1.21];
xHex = [1, 0.5, -0.5, -1, -0.5, 0.5];
yHex = [0, 0.86603, 0.86603, 0, -0.86603, -0.86603];
PG = polyshape( xOct, yOct );
sPG = polyshape( xHex, yHex );
cla;
PG.plot();
hold on;
sPG.plot();
% Need to solve for s.
% s = computeScalingFactor( PG, sPG )
answerPG = scale( PG, 0.3 ); % Second input should be s - ideally, 'computeScalingFactor' or whatever function used to compute s would be about 0.3.
answerPG.plot();

Respuestas (1)

Bruno Luong
Bruno Luong el 27 de Ag. de 2020
scale = sPG.perimeter/PG.perimeter

Categorías

Más información sobre Elementary Polygons en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by