필터 지우기
필터 지우기

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 CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by