-
Notifications
You must be signed in to change notification settings - Fork 0
/
tlgc.m
37 lines (36 loc) · 845 Bytes
/
tlgc.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function [ixR iyR] = tlgc(X,m,n,p)
% Transforms cartesian coordinates onto the voronoi mesh
% p is position in the cell, e.g. 0=center, 1..6 are border positions
% FIX: this is a low-performance version using dynamics memory allocation for a small input-size m
ixR=[];
iyR=[];
inputL = length(m);
for i=1:inputL
if(mod(m(i),2)==0)
iy=n(i)+0.5;
else
iy=n(i);
end
ix=X(m(i));
factor=0.25;
if(p==2)
iy=iy-factor;
ix=ix+factor;
elseif(p==1)
iy=iy+factor;
ix=ix+factor;
elseif(p==6)
iy=iy+factor+0.1;
elseif(p==5)
iy=iy+factor;
ix=ix-factor;
elseif(p==4)
iy=iy-factor;
ix=ix-factor;
elseif(p==3)
iy=iy-factor-0.1;
end
ixR=[ixR; ix];
iyR=[iyR; iy];
end
end