0

I have a rectangular grid with cell centers defined by y-coordinates (array y) and x-coordinates (array x). Interfaces are defined similarly in arrays xi and yi. Then there is a function f(x) that goes through that grid. This could be a simple line but can also be a more complicated curve (hence Bresenham's Algorithm might not work).

Is there a simple (python) way to find all the grid cells that are intersected by the curve?

John Smith
  • 1,059
  • 1
  • 13
  • 35
  • How is `f(x)` given? A formula? A list of `(x, y)` pairs? – Amnon Jan 18 '16 at 13:22
  • Could be either way. Let's for now say is an array with a y value for every entry in the x array. The curve is then a nonlinear interpolation between those values. – John Smith Jan 18 '16 at 13:24
  • Are the x's are ordered by order of appearance on the curve? If so, interpolate y values for the x's between each adjacent pair then round them to the nearest y coordinate. You can improve performance according to the way you interpolate the function values. If it's a straight line, use Bressenham, if another function than you night use a similar method. – Amnon Jan 18 '16 at 14:12
  • @JohnSmith did the linked question answer your problem? – john mangual Jan 18 '16 at 20:11
  • IMO the linked question does not answer this question. – Amnon Jan 19 '16 at 11:34
  • @Amnon - The linked question is an answer to a well specified and simpler version of this question, and even there the answer isn't "simple". So it's not a literal duplicate, but if one goes literal with this question: "Is there a simple...", the answer is just "No". If you or others think it's reasonable to search out ways to interpret this question, and hone down the generalities, and work out how "simple" the answer needs to be for the OP, I'm happy to vote to reopen. Personally, I think the OP should consider this question in light of the others and ask one that's better defined. – tom10 Jan 19 '16 at 17:26

0 Answers0