help with vertex transformations
Afficher commentaires plus anciens
Hello everyone, I am trying to round the corners of my "W" stencil I have created so that it is rounded at the vertices when it turns directions during the plot. Also how can i mimick the degree of the rounded angle? Thank you for any help.
clear all; close all;
trunk = 0.5; % height of each y component
aspect = 1.4; % set the aspect ratio
total_height = 2.5; % total height of letter W
total_width = (25/14);
% selecting points to move around the block
xpos = [(-125/224),-(25/28), -(75/112), -(25/56),-(25/224), (25/224), (25/56),(75/112),(25/28), (125/224),(75/224), 0, -(75/224), -(125/224)];
ypos = [0,total_height, total_height, 0.75, total_height,total_height, 0.75, total_height,total_height, 0,0, 1.875,0,0];
figure(1); % opening a figure]
plot(xpos,ypos,'ko-','Linewidth',1.5) % plotting with thicker lines
grid on; axis equal; % making selections for showing equal size ratios in both directions
axis([1.2*total_width/2*[-1,1],[-.25,1.1*total_height]]) % expanding axes to show full view
text((-125/224),0,'1','VerticalAlignment','top', 'Color', 'r');
text(-(25/28),total_height,'2','VerticalAlignment','bottom', 'Color', 'r');
text(-(75/112),total_height,'3','VerticalAlignment','bottom', 'Color', 'r');
text(-(25/56), 0.75,'4','VerticalAlignment','top', 'Color', 'r');
text(-(25/224), total_height,'5','VerticalAlignment','bottom', 'Color', 'r');
text((25/224), total_height,'6','VerticalAlignment','bottom', 'Color', 'r');
text((25/56), 0.75,'7','VerticalAlignment','top', 'Color', 'r');
text((75/112), total_height,'8','VerticalAlignment','bottom', 'Color', 'r');
text((25/28), total_height,'9','VerticalAlignment','bottom', 'Color', 'r');
text((125/224),0,'10','VerticalAlignment','top', 'Color', 'r');
text((75/224),0,'11','VerticalAlignment','top', 'Color', 'r');
text(0,1.875,'12','VerticalAlignment','bottom', 'Color', 'r');
text(-(75/224),0,'13','VerticalAlignment','top', 'Color', 'r');

3 commentaires
darova
le 4 Mai 2020
I don't understand the question. I don't see any rounded corners. Can you explain more? Show?
random1072
le 5 Mai 2020
random1072
le 5 Mai 2020
Modifié(e) : darova
le 5 Mai 2020
Réponse acceptée
Plus de réponses (1)
Ameer Hamza
le 5 Mai 2020
Try this. It uses smoothdata() to smoothen the edges.
clear all; close all;
trunk = 0.5; % height of each y component
aspect = 1.4; % set the aspect ratio
total_height = 2.5; % total height of letter W
total_width = (25/14);
% selecting points to move around the block
xpos = [(-125/224),-(25/28), -(75/112), -(25/56),-(25/224), (25/224), (25/56),(75/112),(25/28), (125/224),(75/224), 0, -(75/224), -(125/224)];
xpos = interp1(linspace(0,1,numel(xpos)), xpos, linspace(0,1,numel(xpos)*20));
xpos = smoothdata(xpos, 'sgolay', 40);
ypos = [0,total_height, total_height, 0.75, total_height,total_height, 0.75, total_height,total_height, 0,0, 1.875,0,0];
ypos = interp1(linspace(0,1,numel(ypos)), ypos, linspace(0,1,numel(ypos)*20));
ypos = smoothdata(ypos, 'sgolay', 40);
figure(1); % opening a figure]
plot(xpos,ypos,'ko-','Linewidth',1.5) % plotting with thicker lines
grid on; axis equal; % making selections for showing equal size ratios in both directions
axis([1.2*total_width/2*[-1,1],[-.25,1.1*total_height]]) % expanding axes to show full view
text((-125/224),0,'1','VerticalAlignment','top', 'Color', 'r');
text(-(25/28),total_height,'2','VerticalAlignment','bottom', 'Color', 'r');
text(-(75/112),total_height,'3','VerticalAlignment','bottom', 'Color', 'r');
text(-(25/56), 0.75,'4','VerticalAlignment','top', 'Color', 'r');
text(-(25/224), total_height,'5','VerticalAlignment','bottom', 'Color', 'r');
text((25/224), total_height,'6','VerticalAlignment','bottom', 'Color', 'r');
text((25/56), 0.75,'7','VerticalAlignment','top', 'Color', 'r');
text((75/112), total_height,'8','VerticalAlignment','bottom', 'Color', 'r');
text((25/28), total_height,'9','VerticalAlignment','bottom', 'Color', 'r');
text((125/224),0,'10','VerticalAlignment','top', 'Color', 'r');
text((75/224),0,'11','VerticalAlignment','top', 'Color', 'r');
text(0,1.875,'12','VerticalAlignment','bottom', 'Color', 'r');
text(-(75/224),0,'13','VerticalAlignment','top', 'Color', 'r');

Catégories
En savoir plus sur Discrete Data Plots dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

