Skip to content

Commit

Permalink
support cone trunk in meshacylinder
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Oct 2, 2017
1 parent dd20203 commit 9f5e9f1
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions meshacylinder.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
%
% input:
% c0, c1: cylinder axis end points
% r: radius of the cylinder
% r: radius of the cylinder; if r contains two elements, it outputs
% a cone trunk, with each r value specifying the radius on each end
% tsize: maximum surface triangle size on the sphere
% maxvol: maximu volume of the tetrahedral elements
%
Expand All @@ -35,7 +36,11 @@
if(nargin<3)
error('you must at least provide c0, c1, and r');
end
if(r<=0 || all(c0==c1))

if(length(r)==1)
r=[r,r];
end
if(any(r<=0) || all(c0==c1))
error('invalid cylinder parameters');
end
c0=c0(:);
Expand All @@ -49,10 +54,12 @@

dt=2*pi/ndiv;
theta=dt:dt:2*pi;
cx=r*cos(theta);
cy=r*sin(theta);
p0=[cx(:) cy(:) zeros(ndiv,1)];
p1=[cx(:) cy(:) len*ones(ndiv,1)];
cx=r(:)*cos(theta);
cy=r(:)*sin(theta);
cx=cx';
cy=cy';
p0=[cx(:,1) cy(:,1) zeros(ndiv,1)];
p1=[cx(:,2) cy(:,2) len*ones(ndiv,1)];
pp=[p0;p1];
no=rotatevec3d(pp,v0)+repmat(c0',size(pp,1),1);

Expand Down

0 comments on commit 9f5e9f1

Please sign in to comment.