Sideway BICK BlogSideway BICK BLOG from Sideway

A Sideway to Sideway Home

Link:http://output.to/sideway/default.asp?qno=140600012

Matlab Code: dwlinstar

MatLab: Frequently Used Codes

Major Reference Source: MatLab Verson 7.0

MatLab Package is designed for presentations, and therefore all data stored in arrays can be presented graphically.

Simple Line Star Geometry of Cyclic Points

Points are equally spaced in the form of a circle can be used to plot some simple line geometry by joining data points with lines.

dwlinstar

Code:

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

Example

  • Use function dwlinstar with default value to generate a line 5-sided star polygon with starriness equals to 2, circumcircle centre at [0,0] and radius of circumcircle equals to 1.

    Example:

     IMAGE...
     IMAGE...  

  • Use function dwlinstar to generate a line 6-sided star polygon with side n equal to 6, starriness equals to 2, circumcircle centre at [1,4] and radius of circumcircle equals to 5.

    Example:

     IMAGE...  IMAGE...  

  • Use function dwlinstar to generate a line 7-sided star polygon with side n equal to 7, starriness equals to 3, circumcircle centre at [1,4] and radius of circumcircle equals to 5.

    Example:

     IMAGE...  IMAGE...  

  •  

 
Previous Month  JUN  2014  Next Month
SMTWTFS
1234567
891011121314
15161718192021
22232425262728
2930

Previous Month  MAR  2012  Next Month
SMTWTFS
123
45678910
11121314151617
18192021222324
25262728293031

Sideway BICK Blog

21/06


Copyright © 2000-2020 Sideway . All rights reserved Disclaimerslast modified on 26 January 2013