rbmatlab  1.16.09
 All Classes Namespaces Files Functions Variables Modules Pages
local2global.m
1 function glob = local2global(grid,einds,loc,params)
2 %function glob = local2global(grid,einds,loc,params)
3 % function performing a local to global coordinate change of
4 % vectors of coordinate pairs.
5 %
6 % If the three vertices of a triangle are 'v1,v2,v3', then the
7 % global coordinate of a single point is
8 % @code glob = v1 + loc(:,1).*(v2-v1) + loc(:,2).*(v3-v1); @endcode
9 %
10 % Parameters:
11 % loc: matrix of size `K \times 2` holding local barycentric coordinate pairs
12 % for each cell index `i_k`, `k=1,...,K`.
13 % einds: vector of cell indices `i_k`, `k=1,...,K`.
14 %
15 % Return values:
16 % glob: global coordinate pairs '[X, Y]' with vectors 'X' and 'Y'
17 % of length `K`.
18 %
19 
20 % Bernard Haasdonk 2.2.2009
21 
22 % for triagrid:
23 %locs3 = 1-locs(1,:)-locs(2,:);
24 loc3 = 1-loc(1)-loc(2);
25 VI1 = grid.VI(einds,1);
26 VI2 = grid.VI(einds,2);
27 VI3 = grid.VI(einds,3);
28 %X = grid.X(VI1).*locs(1,:)+grid.X(VI2).*locs(2,:)+grid.X(VI3).*locs3;
29 %Y = grid.Y(VI1).*locs(1,:)+grid.Y(VI2).*locs(2,:)+grid.Y(VI3).*locs3;
30 X = grid.X(VI1)'.*loc3+grid.X(VI2)'.*loc(1)+grid.X(VI3)'.*loc(2);
31 Y = grid.Y(VI1)'.*loc3+grid.Y(VI2)'.*loc(1)+grid.Y(VI3)'.*loc(2);
32 %keyboard;
33 glob = [X(:),Y(:)];
34 
A triangular conforming grid in two dimensions.
Definition: triagrid.m:17
VI
matrix of vertex indices: VI(i,j) is the global index of j-th vertex of element i ...
Definition: gridbase.m:65