1 function [P1, P2] = get_edge_points(grid,elids,edgeids)
2 %
function [P1, P2] = get_edge_points(grid,elids,edgeids)
3 %
function extracting edge coordinates from the grid.
5 % Given a grid of dimension `d`,
this function returns the two extremal
6 % coordinates of edges `\{e(i_k, j_k)\}_{k=1}^K` assuming that the edge is
7 % `(d-1)`-dimensional cube. Here, `i_k` are cell indices and `j_k` denotes
8 % local edge numbers
for all `k=1,...,K`
11 % elids: vector of length `K` of cell indices `i_k`.
12 % edgeids: vector of length `K` of local edge indices `j_k`.
15 % P1: matrix of size `K x d` holding the first extremal coordinate of the
16 % edges `e(i_k, j_k)`.
17 % P2: matrix of size `K x d` holding the second extremal coordinate of the
18 % edges `e(i_k, j_k)`.
20 % Bernard Haasdonk 12.5.2007
22 li = sub2ind(size(grid.ECX),elids(:),edgeids(:));
23 edgeids_plus_1 = edgeids + 1;
24 i = edgeids_plus_1 > grid.nneigh;
25 edgeids_plus_1(i) = 1;
26 li_plus_1 = sub2ind(size(grid.ECX),elids(:),edgeids_plus_1(:));
27 P1 = [grid.X(grid.VI(li)),...
29 P2 = [grid.X(grid.VI(li_plus_1)),...
30 grid.Y(grid.VI(li_plus_1))];