rbmatlab 0.10.01
grid/@triagrid/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 three vertices of a triangle 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 %locs3 = 1-locs(1,:)-locs(2,:);
00024 loc3 = 1-loc(1)-loc(2);
00025 VI1 = grid.VI(einds,1);
00026 VI2 = grid.VI(einds,2);
00027 VI3 = grid.VI(einds,3);
00028 %X = grid.X(VI1).*locs(1,:)+grid.X(VI2).*locs(2,:)+grid.X(VI3).*locs3;
00029 %Y = grid.Y(VI1).*locs(1,:)+grid.Y(VI2).*locs(2,:)+grid.Y(VI3).*locs3;
00030 X = grid.X(VI1)'.*loc3+grid.X(VI2)'.*loc(1)+grid.X(VI3)'.*loc(2);
00031 Y = grid.Y(VI1)'.*loc3+grid.Y(VI2)'.*loc(1)+grid.Y(VI3)'.*loc(2);
00032 %keyboard;
00033 glob = [X(:),Y(:)];
00034 
All Classes Namespaces Files Functions Variables