Skip to content

Commit db29097

Browse files
committed
Initial commit R2023a
1 parent a9f54e5 commit db29097

File tree

113 files changed

+1582
-529
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+1582
-529
lines changed
113 Bytes
Binary file not shown.
161 Bytes
Binary file not shown.
Lines changed: 97 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,97 @@
1-
function [xy_data] = Extr_Data_LinkHoles(L, W, r, num_holes, varargin)
2-
%Extr_Data_LinkHoles Produce extrusion data for a link with an arbitrary
3-
%number of holes and rounded ends.
4-
% [xy_data] = Extr_Data_LinkHoles(L, W, r, num_holes)
5-
% This function returns x-y data for a link with half a hole at one end.
6-
% You can specify:
7-
% Length L
8-
% Width W
9-
% Hole radius r
10-
% # holes num_holes
11-
%
12-
% To see a plot showing parameter values, enter the name
13-
% of the function with no arguments
14-
% >> Extr_Data_LinkHoles
15-
%
16-
% To see a plot created with your parameter values,
17-
% add 'plot' as the final argument
18-
% >> Extr_Data_LinkHoles(10,5,1,3,'plot')
19-
%
20-
% Copyright 2014-2023 The MathWorks, Inc.
21-
22-
% Default data to show diagram
23-
if (nargin == 0)
24-
L = 15;
25-
W = 5;
26-
r = 1;
27-
num_holes = 4;
28-
end
29-
30-
% Check if plot should be produced
31-
if (isempty(varargin))
32-
showplot = 'n';
33-
else
34-
showplot = char(varargin);
35-
end
36-
37-
38-
% Half length and width
39-
hl = L / 2;
40-
hw = W / 2;
41-
42-
% Rounded ends and outer boundary of member
43-
theta = (-89:1:+90)' * pi/180; % CCW
44-
rght_end = repmat([hl 0], 180, 1) + hw * [cos(theta), sin(theta)];
45-
left_end = flipud(rght_end) * diag([-1 1]);
46-
boundary = [rght_end; left_end];
47-
48-
% Circular holes
49-
theta = (270:-1:-90)' * pi/180; % CW
50-
hole = [[0 -hw]; r * [cos(theta), sin(theta)]; [0 -hw]];
51-
holes = kron(linspace(-hl, +hl, num_holes)', repmat([1 0], 363, 1)) ...
52-
+ repmat(hole, num_holes, 1);
53-
54-
xy_data = [boundary; holes];
55-
56-
% Plot diagram to show parameters and extrusion
57-
if (nargin == 0 || strcmpi(showplot,'plot'))
58-
% Figure name
59-
figString = ['h1_' mfilename];
60-
% Only create a figure if no figure exists
61-
figExist = 0;
62-
fig_hExist = evalin('base',['exist(''' figString ''')']);
63-
if (fig_hExist)
64-
figExist = evalin('base',['ishandle(' figString ') && strcmp(get(' figString ', ''type''), ''figure'')']);
65-
end
66-
if ~figExist
67-
fig_h = figure('Name',figString);
68-
assignin('base',figString,fig_h);
69-
else
70-
fig_h = evalin('base',figString);
71-
end
72-
figure(fig_h)
73-
clf(fig_h)
74-
75-
% Plot extrusion
76-
patch(xy_data(:,1),xy_data(:,2),[1 1 1]*0.95,'EdgeColor','none');
77-
hold on
78-
plot(xy_data(:,1),xy_data(:,2),'-','Marker','o','MarkerSize',4,'LineWidth',2);
79-
80-
axis('equal');
81-
axis([-1 1 -1 1]*(L+W)*1.1/2);
82-
83-
% Show parameters
84-
plot([-L/2 L/2],[0 0],'r-d','MarkerFaceColor','r');
85-
text(-L/4,W/10,'{\color{red}L}');
86-
plot([L/4 L/4],[-W/2 W/2],'g-d','MarkerFaceColor','g');
87-
text(L/3.8,W/4,'{\color{green}W}');
88-
plot([-L/2 -L/2+r*sin(30*pi/180)],[0 r*cos(30*pi/180)],'k-d','MarkerFaceColor','k');
89-
text(-L/2+r*sin(30*pi/180)*1.4,1.4*r*cos(30*pi/180),'r');
90-
91-
title('[xy\_data] = Extr\_Data\_LinkHoles(L, W, r, num\_holes);');
92-
hold off
93-
box on
94-
clear xy_data
95-
end
96-
97-
1+
function [xy_data] = Extr_Data_LinkHoles(L, W, r, num_holes, varargin)
2+
%Extr_Data_LinkHoles Produce extrusion data for a link with an arbitrary
3+
%number of holes and rounded ends.
4+
% [xy_data] = Extr_Data_LinkHoles(L, W, r, num_holes)
5+
% This function returns x-y data for a link with half a hole at one end.
6+
% You can specify:
7+
% Length L
8+
% Width W
9+
% Hole radius r
10+
% # holes num_holes
11+
%
12+
% To see a plot showing parameter values, enter the name
13+
% of the function with no arguments
14+
% >> Extr_Data_LinkHoles
15+
%
16+
% To see a plot created with your parameter values,
17+
% add 'plot' as the final argument
18+
% >> Extr_Data_LinkHoles(10,5,1,3,'plot')
19+
%
20+
% Copyright 2014-2023 The MathWorks, Inc.
21+
22+
% Default data to show diagram
23+
if (nargin == 0)
24+
L = 15;
25+
W = 5;
26+
r = 1;
27+
num_holes = 4;
28+
end
29+
30+
% Check if plot should be produced
31+
if (isempty(varargin))
32+
showplot = 'n';
33+
else
34+
showplot = char(varargin);
35+
end
36+
37+
38+
% Half length and width
39+
hl = L / 2;
40+
hw = W / 2;
41+
42+
% Rounded ends and outer boundary of member
43+
theta = (-89:1:+90)' * pi/180; % CCW
44+
rght_end = repmat([hl 0], 180, 1) + hw * [cos(theta), sin(theta)];
45+
left_end = flipud(rght_end) * diag([-1 1]);
46+
boundary = [rght_end; left_end];
47+
48+
% Circular holes
49+
theta = (270:-1:-90)' * pi/180; % CW
50+
hole = [[0 -hw]; r * [cos(theta), sin(theta)]; [0 -hw]];
51+
holes = kron(linspace(-hl, +hl, num_holes)', repmat([1 0], 363, 1)) ...
52+
+ repmat(hole, num_holes, 1);
53+
54+
xy_data = [boundary; holes];
55+
56+
% Plot diagram to show parameters and extrusion
57+
if (nargin == 0 || strcmpi(showplot,'plot'))
58+
% Figure name
59+
figString = ['h1_' mfilename];
60+
% Only create a figure if no figure exists
61+
figExist = 0;
62+
fig_hExist = evalin('base',['exist(''' figString ''')']);
63+
if (fig_hExist)
64+
figExist = evalin('base',['ishandle(' figString ') && strcmp(get(' figString ', ''type''), ''figure'')']);
65+
end
66+
if ~figExist
67+
fig_h = figure('Name',figString);
68+
assignin('base',figString,fig_h);
69+
else
70+
fig_h = evalin('base',figString);
71+
end
72+
figure(fig_h)
73+
clf(fig_h)
74+
75+
% Plot extrusion
76+
patch(xy_data(:,1),xy_data(:,2),[1 1 1]*0.95,'EdgeColor','none');
77+
hold on
78+
plot(xy_data(:,1),xy_data(:,2),'-','Marker','o','MarkerSize',4,'LineWidth',2);
79+
80+
axis('equal');
81+
axis([-1 1 -1 1]*(L+W)*1.1/2);
82+
83+
% Show parameters
84+
plot([-L/2 L/2],[0 0],'r-d','MarkerFaceColor','r');
85+
text(-L/4,W/10,'{\color{red}L}');
86+
plot([L/4 L/4],[-W/2 W/2],'g-d','MarkerFaceColor','g');
87+
text(L/3.8,W/4,'{\color{green}W}');
88+
plot([-L/2 -L/2+r*sin(30*pi/180)],[0 r*cos(30*pi/180)],'k-d','MarkerFaceColor','k');
89+
text(-L/2+r*sin(30*pi/180)*1.4,1.4*r*cos(30*pi/180),'r');
90+
91+
title('[xy\_data] = Extr\_Data\_LinkHoles(L, W, r, num\_holes);');
92+
hold off
93+
box on
94+
clear xy_data
95+
end
96+
97+
Lines changed: 100 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,100 @@
1-
function [xy_data] = Extr_Data_TriangleRounded_Holes(L, H, xL, ri, ro, varargin)
2-
%Extr_Data_TriangleRounded_Holes Produce extrusion data for a triangle
3-
%with rounded corners and a hole at each corner. with an arbitrary
4-
% [xy_data] = Extr_Data_TriangleRounded_Holes(L, W, r, h)
5-
% This function returns x-y data for the triangle.
6-
% You can specify:
7-
% Distance between lower holes L
8-
% Distance from line connecting H
9-
% lower holes to uppper hole
10-
% Hole inner radius ri
11-
% Triangle corner radius ro
12-
% Top hole offset (0-1)*L xL
13-
%
14-
% To see a plot showing parameter values, enter the name
15-
% of the function with no arguments
16-
% >> Extr_Data_TriangleRounded_Holes
17-
%
18-
% To see a plot created with your parameter values,
19-
% add 'plot' as the final argument
20-
% >> Extr_Data_TriangleRounded_Holes(10,5,1,2,'plot')
21-
%
22-
% Copyright 2014-2023 The MathWorks, Inc.
23-
24-
% Default data to show diagram
25-
if (nargin == 0)
26-
L = 6;
27-
H = 4;
28-
ri = 1;
29-
ro = 1.5;
30-
xL = 0.33;
31-
end
32-
33-
% Check if plot should be produced
34-
if (isempty(varargin))
35-
showplot = 'n';
36-
else
37-
showplot = char(varargin);
38-
end
39-
40-
% Calculate lengths and angles
41-
ang_R2H = atan2d(H,(xL*L));
42-
ang_F2H = atan2d(H,((1-xL)*L));
43-
44-
xy_data1 = [L -ro];
45-
xy_data2 = [cosd(270:-1:-90); sind(270:-1:-90)]'*ri+[L 0];
46-
xy_data3 = [cosd(-90:1:90-ang_F2H); sind(-90:1:90-ang_F2H)]'*ro+[L 0];
47-
xy_data4 = [cosd(90-ang_F2H); sind(90-ang_F2H)]'*ro+[xL*L H];
48-
xy_data5 = [cosd(90-ang_F2H:-1:(90-ang_F2H-360)); sind(90-ang_F2H:-1:(90-ang_F2H-360))]'*ri+[xL*L H];
49-
xy_data6 = [cosd(90-ang_F2H:1:(ang_R2H+90)); sind(90-ang_F2H:1:(ang_R2H+90))]'*ro+[xL*L H];
50-
xy_data7 = [cosd(ang_R2H+90); sind(ang_R2H+90)]'*ro;
51-
xy_data8 = [cosd((ang_R2H+90):-1:(ang_R2H-270)); sind((ang_R2H+90):-1:(ang_R2H-270))]'*ri;
52-
xy_data9 = [cosd((ang_R2H-270):1:-90); sind((ang_R2H-270):1:-90)]'*ro;
53-
54-
xy_data = [xy_data1; xy_data2; xy_data3; xy_data4; xy_data5;xy_data6; xy_data7;xy_data8;xy_data9];
55-
56-
% Plot diagram to show parameters and extrusion
57-
if (nargin == 0 || strcmpi(showplot,'plot'))
58-
% Figure name
59-
figString = ['h1_' mfilename];
60-
% Only create a figure if no figure exists
61-
figExist = 0;
62-
fig_hExist = evalin('base',['exist(''' figString ''')']);
63-
if (fig_hExist)
64-
figExist = evalin('base',['ishandle(' figString ') && strcmp(get(' figString ', ''type''), ''figure'')']);
65-
end
66-
if ~figExist
67-
fig_h = figure('Name',figString);
68-
assignin('base',figString,fig_h);
69-
else
70-
fig_h = evalin('base',figString);
71-
end
72-
figure(fig_h)
73-
clf(fig_h)
74-
75-
% Plot extrusion
76-
patch(xy_data(:,1),xy_data(:,2),[1 1 1]*0.95,'EdgeColor','none');
77-
hold on
78-
plot(xy_data(:,1),xy_data(:,2),'-','Marker','o','MarkerSize',4,'LineWidth',2);
79-
80-
axis('equal');
81-
82-
% Show parameters
83-
plot([0 L],[0 0],'r-d','MarkerFaceColor','r');
84-
text(L/2,H/15,'{\color{red}L}');
85-
plot([1 1]*xL*L,[0 H],'b-d','MarkerFaceColor','b');
86-
text(xL*L*1.1,H/2,'{\color{blue}H}');
87-
plot([0 ri*sin(30*pi/180)],[0 ri*cos(30*pi/180)],'k-d','MarkerFaceColor','k');
88-
text(ri*sin(30*pi/180)*0.5,0.5*ri*cos(30*pi/180),'ri');
89-
plot([0 ro*cosd(-180)],[0 ro*sind(-180)],'g-d','MarkerFaceColor','g');
90-
text(ri*cosd(-180)*0.5,H/15,'{\color{green}ro}');
91-
plot([0 xL*L],[-1 -1]*ri/2,'m-d','MarkerFaceColor','m');
92-
text(xL*L/2,-ri/2-H/15,'{\color{magenta}xL*L}');
93-
94-
title('[xy\_data] = Extr\_Data\_TriangleRounded\_Holes(L, H, ri, ro, xL);');
95-
hold off
96-
box on
97-
clear xy_data
98-
end
99-
100-
1+
function [xy_data] = Extr_Data_TriangleRounded_Holes(L, H, xL, ri, ro, varargin)
2+
%Extr_Data_TriangleRounded_Holes Produce extrusion data for a triangle
3+
%with rounded corners and a hole at each corner. with an arbitrary
4+
% [xy_data] = Extr_Data_TriangleRounded_Holes(L, W, r, h)
5+
% This function returns x-y data for the triangle.
6+
% You can specify:
7+
% Distance between lower holes L
8+
% Distance from line connecting H
9+
% lower holes to uppper hole
10+
% Hole inner radius ri
11+
% Triangle corner radius ro
12+
% Top hole offset (0-1)*L xL
13+
%
14+
% To see a plot showing parameter values, enter the name
15+
% of the function with no arguments
16+
% >> Extr_Data_TriangleRounded_Holes
17+
%
18+
% To see a plot created with your parameter values,
19+
% add 'plot' as the final argument
20+
% >> Extr_Data_TriangleRounded_Holes(10,5,1,2,'plot')
21+
%
22+
% Copyright 2014-2023 The MathWorks, Inc.
23+
24+
% Default data to show diagram
25+
if (nargin == 0)
26+
L = 6;
27+
H = 4;
28+
ri = 1;
29+
ro = 1.5;
30+
xL = 0.33;
31+
end
32+
33+
% Check if plot should be produced
34+
if (isempty(varargin))
35+
showplot = 'n';
36+
else
37+
showplot = char(varargin);
38+
end
39+
40+
% Calculate lengths and angles
41+
ang_R2H = atan2d(H,(xL*L));
42+
ang_F2H = atan2d(H,((1-xL)*L));
43+
44+
xy_data1 = [L -ro];
45+
xy_data2 = [cosd(270:-1:-90); sind(270:-1:-90)]'*ri+[L 0];
46+
xy_data3 = [cosd(-90:1:90-ang_F2H); sind(-90:1:90-ang_F2H)]'*ro+[L 0];
47+
xy_data4 = [cosd(90-ang_F2H); sind(90-ang_F2H)]'*ro+[xL*L H];
48+
xy_data5 = [cosd(90-ang_F2H:-1:(90-ang_F2H-360)); sind(90-ang_F2H:-1:(90-ang_F2H-360))]'*ri+[xL*L H];
49+
xy_data6 = [cosd(90-ang_F2H:1:(ang_R2H+90)); sind(90-ang_F2H:1:(ang_R2H+90))]'*ro+[xL*L H];
50+
xy_data7 = [cosd(ang_R2H+90); sind(ang_R2H+90)]'*ro;
51+
xy_data8 = [cosd((ang_R2H+90):-1:(ang_R2H-270)); sind((ang_R2H+90):-1:(ang_R2H-270))]'*ri;
52+
xy_data9 = [cosd((ang_R2H-270):1:-90); sind((ang_R2H-270):1:-90)]'*ro;
53+
54+
xy_data = [xy_data1; xy_data2; xy_data3; xy_data4; xy_data5;xy_data6; xy_data7;xy_data8;xy_data9];
55+
56+
% Plot diagram to show parameters and extrusion
57+
if (nargin == 0 || strcmpi(showplot,'plot'))
58+
% Figure name
59+
figString = ['h1_' mfilename];
60+
% Only create a figure if no figure exists
61+
figExist = 0;
62+
fig_hExist = evalin('base',['exist(''' figString ''')']);
63+
if (fig_hExist)
64+
figExist = evalin('base',['ishandle(' figString ') && strcmp(get(' figString ', ''type''), ''figure'')']);
65+
end
66+
if ~figExist
67+
fig_h = figure('Name',figString);
68+
assignin('base',figString,fig_h);
69+
else
70+
fig_h = evalin('base',figString);
71+
end
72+
figure(fig_h)
73+
clf(fig_h)
74+
75+
% Plot extrusion
76+
patch(xy_data(:,1),xy_data(:,2),[1 1 1]*0.95,'EdgeColor','none');
77+
hold on
78+
plot(xy_data(:,1),xy_data(:,2),'-','Marker','o','MarkerSize',4,'LineWidth',2);
79+
80+
axis('equal');
81+
82+
% Show parameters
83+
plot([0 L],[0 0],'r-d','MarkerFaceColor','r');
84+
text(L/2,H/15,'{\color{red}L}');
85+
plot([1 1]*xL*L,[0 H],'b-d','MarkerFaceColor','b');
86+
text(xL*L*1.1,H/2,'{\color{blue}H}');
87+
plot([0 ri*sin(30*pi/180)],[0 ri*cos(30*pi/180)],'k-d','MarkerFaceColor','k');
88+
text(ri*sin(30*pi/180)*0.5,0.5*ri*cos(30*pi/180),'ri');
89+
plot([0 ro*cosd(-180)],[0 ro*sind(-180)],'g-d','MarkerFaceColor','g');
90+
text(ri*cosd(-180)*0.5,H/15,'{\color{green}ro}');
91+
plot([0 xL*L],[-1 -1]*ri/2,'m-d','MarkerFaceColor','m');
92+
text(xL*L/2,-ri/2-H/15,'{\color{magenta}xL*L}');
93+
94+
title('[xy\_data] = Extr\_Data\_TriangleRounded\_Holes(L, H, ri, ro, xL);');
95+
hold off
96+
box on
97+
clear xy_data
98+
end
99+
100+
2.51 KB
Binary file not shown.

0 commit comments

Comments
 (0)