'How to determine normal indices to complex bodies using loops?


if (i >= 0 && i <= NX - 1 && j == 0)
{
   phase[i*NY + j] = phase[i * NY + (j + 1)];
}

NX and NY are integers. As you can see, phase[i * NY + (j + 1)] accesses the vertices next to the wall, where wall vertices are accessed by the if loop as if (i >= 0 && i <= NX - 1 && j == 0) (bottom wall). Here it is simple, but for complex bodies (square, triangle, circle), how can I access the NORMAL/Perpendicular vertices outside the body using for loop? In image, how can I access red vertices with the help of black vertices?

square with unknown

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source