フィルターのクリア

help with vertex transformations

1 回表示 (過去 30 日間)
random1072
random1072 2020 年 5 月 4 日
編集済み: darova 2020 年 5 月 5 日
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 件のコメント
random1072
random1072 2020 年 5 月 5 日
I am trying to make the corners rounded to where they join each other at a 3-5 degree angle instead of a sharp turn at each vertex
random1072
random1072 2020 年 5 月 5 日
編集済み: darova 2020 年 5 月 5 日

サインインしてコメントする。

採用された回答

darova
darova 2020 年 5 月 5 日
編集済み: darova 2020 年 5 月 5 日
Use arc length interpolation and smooth data
[x,y] = pol2cart(-pi:1:pi,5);
tt = [0 cumsum(hypot(diff(x),diff(y)))]; % create arc length
t1 = linspace(0,tt(end),100); % more points
x1 = interp1(tt,x,t1); % interpolate x
y1 = interp1(tt,y,t1); % interpolate y
x2 = smooth(x1,5); % smooth x
y2 = smooth(y1,5); % smooth y
plot(x,y,':')
line(x2,y2)
See here: LINK

その他の回答 (1 件)

Ameer Hamza
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');

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by