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