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