How to make Rounded Edges of rectangle corners with polyshape function ?
Show older comments
hello, everybody
I would like to make the rounded rectangle and I would like them to translated and rotated.
First I tried with rectangle function using 'Curvature' of 1. then I can make the rounded rectangle.
However, it is not possible for them to translated and rotated.
Therefore, I made the rectangle with polyshape function. and it is okay for them to translated and rotated.
However, i do not know how I can make them to have rounded edges.
Could you please helpe me how to make them to rounded edges with polyshape function?
clear; close all; clc;
figure(1); hold on; axis equal
% Before translating and rotating
rectangle('Position',[-14.1276, 226.1976, 6.5929, 9.4184],'FaceColor','r','Curvature',1)
% After translating and rotating
% translate and rotate polygon
x = [-14.1276; -14.1276+6.5929; -14.1276+6.5929; -14.1276];
y = [226.1976; 226.1976; 226.1976+9.4184; 226.1976+9.4184];
p = [x,y];
pgon = polyshape(p);
pgon = translate(pgon,50,-75);
pgon = rotate(pgon,18,[57, 349]);
plot(pgon,'FaceColor','red','FaceAlpha',1)
% object by rectangle function can not translated and rotated.
1 Comment
"However, it is not possible for them to translated and rotated."
fh0 = figure();
rh0 = rectangle('Position',[-14.1276, 226.1976, 6.5929, 9.4184],'FaceColor','r','Curvature',1);
axis equal
fh1 = figure();
ax1 = axes(fh1);
rh1 = copyobj(rh0,ax1);
axis equal
c = [57,349];
m = makehgtform('translate',[50,-75,0],...
'translate',[-c,0], 'zrotate',deg2rad(18), 'translate',[c,0]);
ht = hgtransform('Matrix',m);
set(rh1, 'Parent',ht)
Accepted Answer
More Answers (1)
S M Ragib Shahriar Islam
on 19 Dec 2022
0 votes
Hi, I was also searching for similar type of solution. This following link might help you....
Categories
Find more on Elementary Polygons in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

