-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateSurface.m
More file actions
38 lines (30 loc) · 1.16 KB
/
createSurface.m
File metadata and controls
38 lines (30 loc) · 1.16 KB
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
function armPoints=createSurface(type,radius,length,lengthRes,thetaRes)
%cylinder
if type == 0
r=radius;
y=linspace(0,length,lengthRes);
theta=linspace(0,2*pi,thetaRes);
%memory allocation
armPoints=zeros(lengthRes*thetaRes,3);
%defining points
armPoints(:,1)=r;
armPoints(:,2)=repmat(theta',lengthRes,1);
for ii=0:thetaRes:thetaRes*lengthRes-lengthRes
armPoints(ii+1:ii+thetaRes,3)=y((ii/thetaRes+1));
end
end
%cylinder with growing and then shrinking radius
if type == 1
y=linspace(0,length,lengthRes);
theta=linspace(0,2*pi,thetaRes);
%memory allocation
armPoints=zeros(lengthRes*thetaRes,3);
%defining points
armPoints(1:lengthRes*thetaRes/2,1)=linspace(radius*0.75,radius,lengthRes*thetaRes/2);
armPoints(lengthRes*thetaRes/2+1:lengthRes*thetaRes,1)=linspace(radius,radius*0.75,lengthRes*thetaRes/2);
armPoints(:,2)=repmat(theta',lengthRes,1);
for ii=0:thetaRes:thetaRes*lengthRes-lengthRes
armPoints(ii+1:ii+thetaRes,3)=y((ii/thetaRes+1));
end
end
end