wolffd@0: function p=vis_patch(lattice) wolffd@0: wolffd@0: % VIS_PATCH Defines the basic patches (hexa and rect) used in SOM_CPLANE wolffd@0: % wolffd@0: % p = vis_patch(lattice) wolffd@0: % wolffd@0: % Input and output arguments: wolffd@0: % lattice (string) 'rect', 'hexa' or 'hexagon' wolffd@0: % wolffd@0: % p (matrix) size Lx2, defines the vertices of the patch wolffd@0: % wolffd@0: % This function produces vertex coordinates for a patch presenting wolffd@0: % a map unit in hexagonal or rectangular lattice with its centre in (0,0). wolffd@0: % wolffd@0: % For more help, try 'type vis_patch' or check out online documentation. wolffd@0: % See also SOM_CPLANE, PATCH. wolffd@0: wolffd@0: %%%% DETAILED DESCRIPTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% wolffd@0: % wolffd@0: % vis_patch wolffd@0: % wolffd@0: % SYNTAX wolffd@0: % wolffd@0: % p = vis_patch(lattice) wolffd@0: % wolffd@0: % DESCRIPTION wolffd@0: % wolffd@0: % Forms a map unit patch for SOM_CPLANE function. Mainly a subroutine wolffd@0: % of SOM_CPLANE, although can be used for on its own as well. wolffd@0: % wolffd@0: % REQUIRED INPUT ARGUMENTS wolffd@0: % wolffd@0: % lattice (string) wolffd@0: % wolffd@0: % 'hexa' produces vertex coordiantes for a hexagoanl patch which wolffd@0: % has its center on (0,0), unit width, and a height of wolffd@0: % 1.3334 units. This is not a regular hexagon but such that wolffd@0: % the node which has topological coordinates (a,b) has its wolffd@0: % center in the visualization at coordinates (a,b) for odd wolffd@0: % a and at (a,b+.5) for even a. The non-regular look of the wolffd@0: % patch is taken care simply by changing the axis ratio. wolffd@0: % wolffd@0: % 'rect' produces vertex coordinates for a uniform rectangular patch. wolffd@0: % having its center on (0,0) and unit sidelength. Used as a wolffd@0: % subfunction in SOM_CPLANE. wolffd@0: % wolffd@0: % 'hexagon' produces vertex coordinates for a regular hexagonal patch. wolffd@0: % It may be used in som_cplane if, for some reason, truly wolffd@0: % regular hexagons are needed instead of the default unit wolffd@0: % markers which are not uniform, but have integer wolffd@0: % y-coordinates in the lattice. wolffd@0: % wolffd@0: % OUTPUT ARGUMENTS wolffd@0: % wolffd@0: % p (matrix) The 2-dimensional vertex coordinates: wolffd@0: % wolffd@0: % case 'rect' case 'hexa' case 'hexagon' wolffd@0: % p=[[-.5 -.5];... p=[[0 0.6667];... p=[[0 0.5774];... wolffd@0: % [-.5 .5];... [0.5 0.3333];... [0.5 0.2887];... wolffd@0: % [ .5 .5];... [0.5 -0.3333];... [0.5 -0.2887];... wolffd@0: % [ .5 -.5]]; [0 -0.6667];... [0 -0.5774];... wolffd@0: % [-0.5 -0.3333];... [-0.5 -0.2887];... wolffd@0: % [-0.5 0.3333]]; [-0.5 0.2887]]; wolffd@0: % wolffd@0: % EXAMPLES wolffd@0: % wolffd@0: % som_cplane(vis_patch('rect'),[6 5],'none'); wolffd@0: % % this produces the same result as som_cplane('rect',[6 5], 'none') wolffd@0: % wolffd@0: % som_cplane(vis_patch('hexa'), vis_unit_coord('hexa',[6 5]), 'none'); wolffd@0: % % produces in principle the same result as wolffd@0: % % som_cplane(vis_patch('hexa'),[6 5],'none'), wolffd@0: % % _but_ in this case the axis are not rescaled and the non-regular wolffd@0: % % shape of hexagons can be seen. wolffd@0: % wolffd@0: % som_cplane(vis_patch('hexagon'), som_unit_coords([6 5],'hexa'), 'none'); wolffd@0: % % produces a truly regular hexa lattice wolffd@0: % wolffd@0: % SEE ALSO wolffd@0: % wolffd@0: % vis_unit_coord The default 'hexa' and 'rect' coordinates in visualizations wolffd@0: % som_unit_coords Locations of units on the SOM grid. wolffd@0: wolffd@0: % Copyright (c) 1999-2000 by the SOM toolbox programming team. wolffd@0: % http://www.cis.hut.fi/projects/somtoolbox/ wolffd@0: wolffd@0: % Version 2.0beta Johan 041099 wolffd@0: wolffd@0: if ~ischar(lattice) wolffd@0: error('Input argument should be a string') wolffd@0: else wolffd@0: switch lattice wolffd@0: case 'rect' wolffd@0: p=[[-.5 -.5]; ... wolffd@0: [-.5 .5];... wolffd@0: [.5 .5];... wolffd@0: [.5 -.5]]; wolffd@0: case 'hexagon' wolffd@0: p=[[0 0.5774];... wolffd@0: [0.5 0.2887];... wolffd@0: [0.5 -0.2887];... wolffd@0: [0 -0.5774];... wolffd@0: [-0.5 -0.2887];... wolffd@0: [-0.5 0.2887]]; wolffd@0: case 'hexa' wolffd@0: p=[[0 0.6667];... wolffd@0: [0.5 0.3333];... wolffd@0: [0.5 -0.3333];... wolffd@0: [0 -0.6667];... wolffd@0: [-0.5 -0.3333];... wolffd@0: [-0.5 0.3333]]; wolffd@0: otherwise wolffd@0: error('Unknown lattice'); wolffd@0: end wolffd@0: end wolffd@0: wolffd@0: