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

2 vues (au cours des 30 derniers jours)
Dominik Mattioli
Dominik Mattioli le 27 Août 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();

Réponses (1)

Bruno Luong
Bruno Luong le 27 Août 2020
scale = sPG.perimeter/PG.perimeter

Catégories

En savoir plus sur Elementary Polygons dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by