annotate toolboxes/MIRtoolbox1.3.2/somtoolbox/vis_patch.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function p=vis_patch(lattice)
Daniel@0 2
Daniel@0 3 % VIS_PATCH Defines the basic patches (hexa and rect) used in SOM_CPLANE
Daniel@0 4 %
Daniel@0 5 % p = vis_patch(lattice)
Daniel@0 6 %
Daniel@0 7 % Input and output arguments:
Daniel@0 8 % lattice (string) 'rect', 'hexa' or 'hexagon'
Daniel@0 9 %
Daniel@0 10 % p (matrix) size Lx2, defines the vertices of the patch
Daniel@0 11 %
Daniel@0 12 % This function produces vertex coordinates for a patch presenting
Daniel@0 13 % a map unit in hexagonal or rectangular lattice with its centre in (0,0).
Daniel@0 14 %
Daniel@0 15 % For more help, try 'type vis_patch' or check out online documentation.
Daniel@0 16 % See also SOM_CPLANE, PATCH.
Daniel@0 17
Daniel@0 18 %%%% DETAILED DESCRIPTION %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Daniel@0 19 %
Daniel@0 20 % vis_patch
Daniel@0 21 %
Daniel@0 22 % SYNTAX
Daniel@0 23 %
Daniel@0 24 % p = vis_patch(lattice)
Daniel@0 25 %
Daniel@0 26 % DESCRIPTION
Daniel@0 27 %
Daniel@0 28 % Forms a map unit patch for SOM_CPLANE function. Mainly a subroutine
Daniel@0 29 % of SOM_CPLANE, although can be used for on its own as well.
Daniel@0 30 %
Daniel@0 31 % REQUIRED INPUT ARGUMENTS
Daniel@0 32 %
Daniel@0 33 % lattice (string)
Daniel@0 34 %
Daniel@0 35 % 'hexa' produces vertex coordiantes for a hexagoanl patch which
Daniel@0 36 % has its center on (0,0), unit width, and a height of
Daniel@0 37 % 1.3334 units. This is not a regular hexagon but such that
Daniel@0 38 % the node which has topological coordinates (a,b) has its
Daniel@0 39 % center in the visualization at coordinates (a,b) for odd
Daniel@0 40 % a and at (a,b+.5) for even a. The non-regular look of the
Daniel@0 41 % patch is taken care simply by changing the axis ratio.
Daniel@0 42 %
Daniel@0 43 % 'rect' produces vertex coordinates for a uniform rectangular patch.
Daniel@0 44 % having its center on (0,0) and unit sidelength. Used as a
Daniel@0 45 % subfunction in SOM_CPLANE.
Daniel@0 46 %
Daniel@0 47 % 'hexagon' produces vertex coordinates for a regular hexagonal patch.
Daniel@0 48 % It may be used in som_cplane if, for some reason, truly
Daniel@0 49 % regular hexagons are needed instead of the default unit
Daniel@0 50 % markers which are not uniform, but have integer
Daniel@0 51 % y-coordinates in the lattice.
Daniel@0 52 %
Daniel@0 53 % OUTPUT ARGUMENTS
Daniel@0 54 %
Daniel@0 55 % p (matrix) The 2-dimensional vertex coordinates:
Daniel@0 56 %
Daniel@0 57 % case 'rect' case 'hexa' case 'hexagon'
Daniel@0 58 % p=[[-.5 -.5];... p=[[0 0.6667];... p=[[0 0.5774];...
Daniel@0 59 % [-.5 .5];... [0.5 0.3333];... [0.5 0.2887];...
Daniel@0 60 % [ .5 .5];... [0.5 -0.3333];... [0.5 -0.2887];...
Daniel@0 61 % [ .5 -.5]]; [0 -0.6667];... [0 -0.5774];...
Daniel@0 62 % [-0.5 -0.3333];... [-0.5 -0.2887];...
Daniel@0 63 % [-0.5 0.3333]]; [-0.5 0.2887]];
Daniel@0 64 %
Daniel@0 65 % EXAMPLES
Daniel@0 66 %
Daniel@0 67 % som_cplane(vis_patch('rect'),[6 5],'none');
Daniel@0 68 % % this produces the same result as som_cplane('rect',[6 5], 'none')
Daniel@0 69 %
Daniel@0 70 % som_cplane(vis_patch('hexa'), vis_unit_coord('hexa',[6 5]), 'none');
Daniel@0 71 % % produces in principle the same result as
Daniel@0 72 % % som_cplane(vis_patch('hexa'),[6 5],'none'),
Daniel@0 73 % % _but_ in this case the axis are not rescaled and the non-regular
Daniel@0 74 % % shape of hexagons can be seen.
Daniel@0 75 %
Daniel@0 76 % som_cplane(vis_patch('hexagon'), som_unit_coords([6 5],'hexa'), 'none');
Daniel@0 77 % % produces a truly regular hexa lattice
Daniel@0 78 %
Daniel@0 79 % SEE ALSO
Daniel@0 80 %
Daniel@0 81 % vis_unit_coord The default 'hexa' and 'rect' coordinates in visualizations
Daniel@0 82 % som_unit_coords Locations of units on the SOM grid.
Daniel@0 83
Daniel@0 84 % Copyright (c) 1999-2000 by the SOM toolbox programming team.
Daniel@0 85 % http://www.cis.hut.fi/projects/somtoolbox/
Daniel@0 86
Daniel@0 87 % Version 2.0beta Johan 041099
Daniel@0 88
Daniel@0 89 if ~ischar(lattice)
Daniel@0 90 error('Input argument should be a string')
Daniel@0 91 else
Daniel@0 92 switch lattice
Daniel@0 93 case 'rect'
Daniel@0 94 p=[[-.5 -.5]; ...
Daniel@0 95 [-.5 .5];...
Daniel@0 96 [.5 .5];...
Daniel@0 97 [.5 -.5]];
Daniel@0 98 case 'hexagon'
Daniel@0 99 p=[[0 0.5774];...
Daniel@0 100 [0.5 0.2887];...
Daniel@0 101 [0.5 -0.2887];...
Daniel@0 102 [0 -0.5774];...
Daniel@0 103 [-0.5 -0.2887];...
Daniel@0 104 [-0.5 0.2887]];
Daniel@0 105 case 'hexa'
Daniel@0 106 p=[[0 0.6667];...
Daniel@0 107 [0.5 0.3333];...
Daniel@0 108 [0.5 -0.3333];...
Daniel@0 109 [0 -0.6667];...
Daniel@0 110 [-0.5 -0.3333];...
Daniel@0 111 [-0.5 0.3333]];
Daniel@0 112 otherwise
Daniel@0 113 error('Unknown lattice');
Daniel@0 114 end
Daniel@0 115 end
Daniel@0 116
Daniel@0 117