rbmatlab 0.10.01
grid/@rectgrid/local2global.m
00001 function glob = local2global(grid,einds,loc,params)
00002 %function glob = local2global(grid,einds,loc,params)
00003 % function performing a local to global coordinate change of
00004 % vectors of coordinate pairs.
00005 %
00006 % If the first three vertices of a rectangle are 'v1,v2,v3', then the
00007 % global coordinate of a single point is
00008 % @code glob = v1 + loc(:,1).*(v2-v1) + loc(:,2).*(v3-v1); @endcode
00009 %
00010 % Parameters:
00011 %  loc: matrix of size `K \times 2` holding local barycentric coordinate pairs
00012 %       for each cell index `i_k`, `k=1,...,K`.
00013 %  einds: vector of cell indices `i_k`, `k=1,...,K`.
00014 %
00015 % Return values:
00016 %  glob: global coordinate pairs '[X, Y]' with vectors 'X' and 'Y'
00017 %        of length `K`.
00018 %
00019 
00020 % Bernard Haasdonk 2.2.2009
00021 
00022 % for triagrid:
00023 
00024 loc3 = loc(1)-loc(2);
00025 VI1 = grid.VI(einds,4);
00026 VI2 = grid.VI(einds,1);
00027 VI3 = grid.VI(einds,2);
00028 
00029 X = grid.X(VI1)' + loc(1).* (grid.X(VI2)' - grid.X(VI1)');
00030 Y = grid.Y(VI1)' + loc(2).* (grid.Y(VI3)' - grid.Y(VI1)');
00031 
00032 glob = [X(:),Y(:)];
00033 
All Classes Namespaces Files Functions Variables