0

I have many finite-length curves in XY domain. These curves are represented as collections of points.

I need to discretize my area by rectangles (or triangles) so that each rectangle (or triangle) is crossed by more than 2 curves and less than 5 curves for example. Even if there is no point in any rectangle but the interpolated curve is in that rectangle, then this curve crosses that rectangle. Edges of neighbor rectangles should stand close to each other (touch each other) and these rectangles should cover all the area where curves exist.

As an output I need to get XY coordinate of each rectangle (triangle). I tried to explain my problem in the picture below. So maybe somebody knows how to solve this problem or the problem is already solved. I would appreciate any information! I'm tryng to implement this in Matlab and I'm wondering is it possible to solve this with linprog() function in Matlab?

Thank you!

To plot curves use:

clearvars -except Gpath
clc

nG = size(Gpath,1);
mG = size(Gpath,2);

figure;
for n = 1:nG*mG
if ~isempty(Gpath{n})
    plot(Gpath{n}(2,:),Gpath{n}(1,:));
    hold on;
end
end
grid on;

Image: 2D Area with rectangles

File with curves: .mat file

Kerim
  • 171
  • 3
  • 10
  • 1
    The word "line" has a distinct meaning in mathematics, implying that it is 1) straight and 2) infinite. From the looks of your image, neither of those two properties are true here. I think the intended meaning may be that you have many finite curves (i.e. not necessarily straight and having a finite length). Is this correct? Also, does "Edges of rectangles should stand close to each other" mean the edges must touch each other, as in your image? or merely be "close"? If the second, how do you define "close"? – JMikes Jul 06 '19 at 15:39
  • JMike, you are right! Instead of word "lines" I should have used "curves" (they have some curvature and finite length). And yes, edges of neighbor rectangles shoud touch each other. Thank you for clarification, I'm going to correct my question. – Kerim Jul 06 '19 at 22:32
  • Thanks for clarifying. Particularly given that there have not been any other responses thus far, I would recommend providing some sample data (e.g. the points defining the curves) and any attempts that you've made thus far that might help others start on the problem (e.g. in what way would linprog() be applied to this problem?). Also, are you looking for a solution to a particular case only or do you need a generalizable solution? For instance, for a generalizable solution, there are trivial cases where a solution does not exist (e.g. if >=5 curves intersect at a single point) – JMikes Jul 07 '19 at 17:40
  • JMike, I've been thinking and searching some information on my task for few days but I only found function like histcounts2() that doesn't solve my problem. Maybe I could write a code that perform something that I need but it would be time-consuming solution that includes loops. – Kerim Jul 10 '19 at 14:13
  • The solution I'm looking for is based on solving linear equations in least squares manner, or maybe based on Markov Chain, or based on neural networks. I don't know how to create system of equations beacause I don't know the number of unknowns and I haven't worked with Markov Chain and neither with neural networks. But I feel there should be a tricky solution. I attach the file with curves and code to plot them. – Kerim Jul 10 '19 at 14:22

0 Answers0