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

조회 수: 2 (최근 30일)
Dominik Mattioli
Dominik Mattioli 2020년 8월 27일
답변: Bruno Luong 2020년 8월 27일
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();

답변 (1개)

Bruno Luong
Bruno Luong 2020년 8월 27일
scale = sPG.perimeter/PG.perimeter

카테고리

Help CenterFile Exchange에서 Elementary Polygons에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by