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 first three vertices of a rectangle 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 
24 loc3 = loc(1)-loc(2);
25 VI1 = grid.VI(einds,4);
26 VI2 = grid.VI(einds,1);
27 VI3 = grid.VI(einds,2);
28 
29 X = grid.X(VI1)' + loc(1).* (grid.X(VI2)' - grid.X(VI1)');
30 Y = grid.Y(VI1)' + loc(2).* (grid.Y(VI3)' - grid.Y(VI1)');
31 
32 glob = [X(:),Y(:)];
33 
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