# Finding boundary intersection points with Cartesian grid?

I would like to find the intersection points e.g. $M_x$ and $M_y$ as in the attached figure. The boundary (solid line) is defined by the Lagrangian points. I am working in C++ (basic - medium proficiency).

In this regard, I need a computer algorithm or code to get the intersection points both in x- and y-in a separate arrays. • Is the boundary defined analytically or how is defined? Can you use marching squares? – nicoguaro Jun 28 '16 at 4:07
• The boundary is defined parametrically, e,g, if we assume a circular boundary, the parametric equations to compute x and y-coordinates of the boundary are: $x = x_{center} + radius*cos(\theta)$ and $y = y_{center} + radius*sin(\theta)$ where $\theta = \pi*index/N_{pts}$. However, the points/boundary can be defined as an input file with a pre-calculated coordinates. – TheCoder Jun 28 '16 at 5:24
• @nicoguaro: Can you give the minimal algorithm for the particular problem under question using Marching Squares? One thing, boundary is moving with time and at each time step position is determined and updated. – TheCoder Jun 30 '16 at 9:35
• I don't have it. You should probably get the signed function for you curve, then apply the marching squares algorithm. You can repeat the process for each timestep – nicoguaro Jun 30 '16 at 14:22