%% Turning Distance Between Two Squares
% Create and plot two squares of different sizes and locations, represented as polyshape objects poly1 and poly2.

poly1 = nsidedpoly(4,'SideLength',1);
poly2 = nsidedpoly(4,'SideLength',3,'Center',[3 3]);
plot(poly1)
hold on 
plot(poly2)
axis equal
hold off

% Because the two squares have the same shape despite their scaling, their turning distance is 0.

td = turningdist(poly1,poly2)

% Create and plot a third polyshape, and compare its turning distance to poly1. Since their shapes have more differences than poly1 and poly2, the turning distance is larger.

poly3 = nsidedpoly(20,'Center',[3 3]);
plot(poly1)
hold on
plot(poly3)
axis equal
hold off
td = turningdist(poly1,poly3)

% Copyright 2012 The MathWorks, Inc.