forked from wspr/hatze-biomech
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_cylinder_hollow.m
39 lines (31 loc) · 1.07 KB
/
plot_cylinder_hollow.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function plot_cylinder_hollow( O, r, R, h, t, varargin )
%%
p = inputParser;
p.addParamValue('rotate',[0 0 0]);
p.addParamValue('N',20);
p.addParamValue('colour',[0.5 0 0.5]);
p.addParamValue('opacity',0.5);
p.addParamValue('edgeopacity',0.5);
p.parse(varargin{:})
N = p.Results.N;
Rot = rotation_matrix_zyx(p.Results.rotate);
col = p.Results.colour;
opac = p.Results.opacity;
eopac = p.Results.edgeopacity;
theta1 = linspace(t(1),t(2),N);
theta2 = linspace(t(2),t(1),N);
p1x = [r*cosd(theta1) R*cosd(theta2)];
p1y = [r*sind(theta1) R*sind(theta2)];
p1z = zeros(1,2*N);
p2z = h*ones(1,2*N);
p1 = Rot*[p1y p1y(1);p1z p1z(1);p1x p1x(1)];
p2 = Rot*[p1y p1y(1);p2z p2z(1);p1x p1x(1)];
patch(O(1)+p1(1,:),O(2)+p1(2,:),O(3)+p1(3,:),col,'facealpha',opac,'edgealpha',eopac)
patch(O(1)+p2(1,:),O(2)+p2(2,:),O(3)+p2(3,:),col,'facealpha',opac,'edgealpha',eopac)
for ii = [1:N-1 N:2*N]
patch(...
O(1)+[p1(1,ii) p2(1,ii) p2(1,ii+1) p1(1,ii+1)],...
O(2)+[p1(2,ii) p2(2,ii) p2(2,ii+1) p1(2,ii+1)],...
O(3)+[p1(3,ii) p2(3,ii) p2(3,ii+1) p1(3,ii+1)],col,'facealpha',opac,'edgealpha',eopac)
end
end