function varargout=dwlinstar(varargin)
%dwlinstar plots 2D line star geometry
% (same as dwlingeom when starriness equals to 1)
% (side
n must be greater or
equal to 5)
% (side n/stairiness r must be greater than 2)
%
% varargout: ([a],[b],[c])
%
% varargint: ([a],[b],[c],[d],[e])
%
% dwlingeom
% to plot a 5-sided line star polygon with starriness equals to 2, circumcircle
centre at [0,0] and radius of circumcircle equals to 1.
%
%
% dwlingeom(n)
% for n>=5, a line star polygon of n sides is plotted with starriness equals to
2, circumcircle centre at [0,0] and radius of circumcircle equals to 1.
% to plot a n-sided line star polygon with starriness equals to 2, circumcircle
centre at [0,0] and radius of circumcircle equals to 1.
%
% dwlingeom(n,s)
% to plot a n-sided line star polygon with starriness equals to s, circumcircle
centre at [0,0] and radius of circumcircle equals to 1.
%
% dwlingeom(n,s,r)
% to plot a n-sided line star polygon with starriness equals to s, circumcircle
centre at [0,0] and radius of circumcircle equals to r.
%
% dwlingeom(n,s,r,x)
% to plot a n-sided line star polygon with starriness equals to s, circumcircle
centre at [x,0] and radius of circumcircle equals to r.
%
% dwlingeom(n,s,r,x,y)
% to plot a n-sided line star polygon with starriness equals to s, circumcircle
centre at [x,y] and radius of circumcircle equals to r.
%
% ---------
% Copyright (c) 2014, All Right Reserved, http://sideway.hk/
% LastChanged:21/06/2014
% version:000.00001 created 20/06/2014 from sideway.hk
%
%
if nargin==0
n=5;s=2;r=1;x=0;y=0;
elseif nargin==1
n=varargin{1};s=2;r=1;x=0;y=0;
elseif nargin==2
n=varargin{1};s=varargin{2};r=1;x=0;y=0;
elseif nargin==3
n=varargin{1};s=varargin{2};r=varargin{3};x=0;y=0;
elseif nargin==4
n=varargin{1};s=varargin{2};r=varargin{3};x=varargin{4};y=0;
elseif nargin==5
n=varargin{1};s=varargin{2};r=varargin{3};x=varargin{4};y=varargin{5};
else
error('in argument more than five');
end
if n<5
error('side
must be greater or equal to 5');
end
if n/r<=2
error('side n/stairiness r must be greater than 2');
end
[a,b]=dwcirspace(n,r,x,y);con=gcd(n,s);
if con>1
i1=mod(s*(1:n/con+1)-(s-1),n);i1(i1==0)=n;
aa=[];bb=[];i1=mod(i1(1:n/con+1),n);i1(i1==0)=n;
for i2=0:con-1 for i2=0:con-1
i3=mod(i1+i2,n);i3(i3==0)=n;
aa=vertcat(aa,a(i3));bb=vertcat(bb,b(i3));vertcat(bb,b(i3));
end
a=aa';b=bb';
else
i1=mod(s*(1:(n+1))-(s-1),n);i1(i1==0)=n;a=a(i1);,b=b(i1);
end
if nargout==0
plot(a,b);
elseif nargout==1
ha=plot(a,b);
varargout{1}=ha;
elseif nargout==2
ha=plot(a,b);
varargout{1}=ha;
varargout{2}=[a,b];
elseif nargout==3
ha=plot(a,b);
varargout{1}=ha;
varargout{2}=a;
varargout{3}=b;
else
error('out argument more than three');
end