Is there a metric for computing the "scale" between two polygons?
조회 수: 1(최근 30일)
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 );
% 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.