This is the fourth part of a series of assignments about wayfinding. The final goal of this series is to be able to calculate the fastest route through a terrain of areas with different properties. The assignments will build on top of each other, gradually increasing the complexity, but guiding you stepwise towards the final goal. You can re-use code from preceding assignments to save some work. See [1] [2] [3].
Which areas are traversed?
For this fourth assignment in this series you have to calculate which areas are traversed and in which order, while going from A to B. Our path from A to B is a straight line. And the area boundaries are closed polygons consisting of a finite number of straight segments. Quite similar to assignment 3.
However, now the areas may overlap. If case of traversing overlapping areas, the area with the highest index in F is the one listed. If an area is crossed twice, it is listed twice in the returned vector. And if AB crosses first for example area F2, then F3, and then F2 again, the output vector should contain [ ... 2 3 2 ... ]. That would also be the case when F3 is contained in F2. But when F2 is contained in F3, then F2 is never crossed, as it has a lower index in F than F3. Consider the areas non-transparent and stacked on top of each other.
The inputs of the function WayfindingPassed(AB,F) are a matrix AB of two columns, each with x-y coordinates, of our straight path from A (1st column) to B (2nd column), and a cell array F of 2-D matrices with columns with x- and y-coordinates, each column a subsequent node of the polygon boundary of the area. The last node is implicitly connected to the first. The index of each area, to be referred to in the output vector, is equal to its position in the cell array F.
AB = [ xA xB yA yB ]
F = { [ x11 x12 ... x1n ; y11 y12 ... y1n ] [ x21 x22 ... x2n ; y21 y22 ... y2n ] }
Your output f will contain the indices in F of the crossed areas, in the correct order. In the example above, the correct answer is [ 3 1 4 1 4 1]. Crossing means 'being present in that area', so if A, the start, is in area 3, it is considered as 'crossed'.
2116 Solvers
Find the alphabetic word product
2118 Solvers
45 Solvers
first step for Huffman Coding (easy)
30 Solvers
Create matrix of replicated elements
275 Solvers
Problem Tags