help with vertex transformations
显示 更早的评论
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 个评论
darova
2020-5-4
I don't understand the question. I don't see any rounded corners. Can you explain more? Show?
random1072
2020-5-5
random1072
2020-5-5
编辑:darova
2020-5-5
采纳的回答
更多回答(1 个)
Ameer Hamza
2020-5-5
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');

类别
在 帮助中心 和 File Exchange 中查找有关 Discrete Data Plots 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

