I have a geometry of a square with 4 edges. Each edge has 5 points and 4 cells (subdivisons). The image bellow illustrates it.
If I have a line going from, say cell(1), Ind(1), Edge(1), I want to define all its possible intersections with the rest of the cells in the remaining 3 edges. So, for example, a line going from cell(1), Ind(1), Edge(1), can intersect with cells of indices 5, 6, 7 ,...., 16. And then, do the same for the next cell. And so on so forth. Each cell has three possible edges to intersect with one of their cells.
This is my attempt of the code.
SL(j) = sqrt((sx(j)-sx(jp))^2+(sy(j)-sy(jp))^2);
nPoint(j) = round(SL(j)/ds);
cPoint(j) = sum(nPoint(1:j));
nSubDiv(j) = nPoint(j) - 1;
cSubDiv(j) = sum(nSubDiv(1:j));
pInd(i,j) = nPoint(1)*(j-1)+i;
sInd(k,j) = nSubDiv(1)*(j-1)+k;
pInd = reshape(pInd(:,:),ns,1);
sInd = reshape(sInd(:,:),nSubDiv(1)*nSubDiv(1),1);
Any help would be appreicted.