| 
    
 Draft for Information Only 
    Content
     
    MatLab: Frequently Used Codes   
                    Simple Line Geometry of Cyclic Points    
                    dwlingeom    
                    Example
 
    
    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 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.  
                
                    dwlingeom
    
        Code:
        
            
                function varargout=dwlingeom(varargin) 
                %dwlingeom plots 2D line polygon
                 
                %
                 
                % dwlingeom
                 
                % to plot a 100-sided line polygon with circumcircle centre at [0,0] and radius 
                of circumcircle equals to 1.
                 
                %
                 
                % varargout: ([],[a],[b],[c])
                 
                %
                 
                % varargint: ([a],[b],[c],[d])
                 
                %
                 
                % dwlingeom(n)
                 
                % for n=1, one single point is plotted 
                at y equals to 0 and x equals to 0 plus offset radius 1 based on circumcircle 
                centre at [0,0].
                 
                % for n=2, a line is plotted parallel to x-axis at y equals to 0 and x equals to 
                0 plus offset radius 1 based on circumcircle centre at [0,0]. 
                 
                % for n>=3, a line polygon of n sides is plotted.
                  
                % to plot a n-sided line polygon with circumcircle centre at [0,0] and radius of 
                circumcircle equals to 1.
                 
                %
                 
                % dwlingeom(n,r)
                 
                % to plot a n-sided line polygon with circumcircle centre at [0,0] and radius of 
                circumcircle equals to r.
                 
                %
                 
                % dwlingeom(n,r,x)
                 
                % to plot a n-sided line polygon with circumcircle centre at [x,0] and radius of 
                circumcircle equals to r.
                 
                %
                 
                % dwlingeom(n,r,x,y)
                 
                % to plot a n-sided line polygon with circumcircle centre at [x,y] and radius of 
                circumcircle equals to r. 
                % 
                % --------- 
                % Copyright (c) 2014, All Right Reserved, http://sideway.hk/  
                % LastChanged:20/06/2014 
                % version:000.00001 created 20/06/2014 from sideway.hk 
                % 
                % 
                if nargin==0 
                n=100;r=1;x=0;y=0; 
                elseif nargin==1 
                n=varargin{1};r=1;x=0;y=0; 
                elseif nargin==2 
                n=varargin{1};r=varargin{2};x=0;y=0; 
                elseif nargin==3 
                n=varargin{1};r=varargin{2};x=varargin{3};y=0; 
                elseif nargin==4 
                n=varargin{1};r=varargin{2};x=varargin{3};y=varargin{4}; 
                else 
                error('in argument more than four'); 
                end 
                [a,b]=dwcirspace(n,r,x,y); 
                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
                    dwlingeom with default value to generate a line 100-sided polygon with 
                circumcircle centre at [0,0] and radius of circumcircle equals to 1. 
    
                 
        - 
            
                Use function dwlingeom with n=5 to generate a line regular pentagon with 
                circumcircle centre at [0,0] and radius of circumcircle equals to 1. 
    
                 
        - 
            
                Use function dwlingeom with n=3 to generate a line equilateral triangle with 
                circumcircle centre at [0,0] and radius of circumcircle equals to 5. 
    
                 
        - 
            
                Use function dwlingeom with n=2 to generate a line with 
                circumcircle centre at [0,0] and radius of circumcircle equals to 5, i.e. a line 
                from [5,0] to [-5,0]. 
    
                 
        - 
            
                Use function dwlingeom with n=1 to 
                plot a point at circle centre [4,5] with circle radius r equal to 2, i.e. a 
                point at [6,5]. 
    
                 
        - 
            
                  
         
     
  
 
     ©sideway 
    ID: 140600011 Last Updated: 6/20/2014 Revision: 0 
    
    
            | 
      |