Hi A LL,
I understand that you need a clever way to identify specific regions on a map.
To break it down and approach the problem systematically, you could leverage a combination of techniques related to computational geometry (specifically alpha shapes, in this case). Here’s a step-by-step guide to help you define and partition the regions effectively:
- Since you already use the “inShape” function with your “alphaShape” object to define regions A (blue) and BCEF (red), make sure the identification process works for both fixed and variable shapes. You might want to verify that the “inShape” function returns points inside the desired polygon for both shapes.
You can refer to the following code for reference:
alphaShapeObj = alphaShape(x_points, y_points, alpha);
inA = inShape(alphaShapeObj, x_points, y_points);
inBCEF = inShape(alphaShapeObj, xstart, ystart);
2. To partition region BCEF into regions B, C, E, and F, there are several methods you could try, but a good way to start is by investigating whether these regions can be distinguished using boundary points or contour lines. You may need additional information, such as a contour map of the regions (e.g., from your start and end files), or partitioning the region using geometric methods.
3. One approach is to use a “Voronoi diagram” or “Delaunay triangulation” to divide up the space inside the “alphaShape” into regions. The idea is to partition the space based on proximity to certain points (like your start or end points). You can use the “voronoi“ function in MATLAB or Delaunay triangulation to help separate the regions.
For example, using a Delaunay triangulation:
DT = delaunayTriangulation(xstart, ystart);
Then, depending on the specific location and boundary points, you could assign the regions (B, C, E, F) based on how these triangles or Voronoi cells relate to the positions of your start and end points.
4. If the regions inside BCEF are contiguous and non-overlapping, you might be able to use the “numRegions” function from the “alphaShape” object to check how many connected sub-regions exist in BCEF. Then, based on proximity or distances from boundary points (such as from xstart, ystart), you can map the regions B, C, E, and F to their respective points.
numRegions = numRegions(alphaShapeObj);
regionPoints = regionPoints(alphaShapeObj, i);
5. You can automate the process of assigning the regions B, C, E, and F based on boundary conditions (e.g., based on proximity to start and end points). This might involve checking if the point belongs to a region inside the boundary defined by “xstart”, “ystart” (orange contour), and then checking if it lies within the purple contour (“xend”, ”yend”).
6. Once you have an initial method for partitioning, you’ll would want to iterate and refine the process. You could consider:
- Using additional geometric properties like the convex hull of the regions to determine boundaries.
- Checking the angle or distance between points to better define each sub-region (B, C, E, F).
- Adjusting the algorithm to account for more complex shapes.
You can read more about “alphaShape” here:
Hope it helps!