3

I'm looking for a solution to calculate the boundary of an irregular shape.

Lats take a look at Square example: Simple Square

if i have Minimum x and y and Maximum x and y like:

MaxX = 5
MinX = 1
MaxY = 5
MinY = 1

in python language:

#Python Code
X = {"Min":1, "Max":5} # is Dictionary of x Axis
Y = {"Min":1, "Max":5} # is Dictionary of y Axis

I can check if any coordinate is in the square boundary or not, simpley by comparing the axis against min and max of square boundary.

now let's look at these 2 irregular example: enter image description here enter image description here

Now how can i calculate the boundary and coordinates of the shape? i do have the point coordinate but i don't have the coordinates inside the shape and lines coordinate that connecting every points of the shape.

Note: you might suggest for Point-in-Polygon but that's like calculating every time for specific coordinate, and if shape is huge it will take time.

Note: even if you heard of a solution in any book, speech, video, website, or even you are guessing, please do let me know in the comment, that could help me out.

Aracthor
  • 5,757
  • 6
  • 31
  • 59
Bear
  • 550
  • 9
  • 25
  • 1
    Hace you tried to detect corners? If it si on images, then I suggest you to use dome kind of library specialised on this (like OpenCV). Do it in 2 parts: detect and interpret the scales, then detect the corners in the shape and interpret their points – sop Jan 14 '16 at 08:32
  • 2
    What you want to determine is the "concave hull" of the shape...not the convex hull. Your first figure shows the minimum area bounding rectangle, the second i the convex hull and the final figure is the concave hull (see alpha shapes as well) –  Jan 14 '16 at 09:26
  • @sop OpenCV, never heard about it, i'll look into it, thanks a lot. – Bear Jan 14 '16 at 16:16
  • @DanPatterson i see... i'm not familiar with those terms, thanks for pointing them out. – Bear Jan 14 '16 at 16:23

1 Answers1

2

If you want to get full list of integer coordinates inside the shape, consider using of floodfill algorithm

MBo
  • 77,366
  • 5
  • 53
  • 86
  • How would you know where to start from? – sop Jan 14 '16 at 16:21
  • 1
    @sop when i create a shape, each point of it have a number, it's only matter of finding clockwise and counter/Anti clockwise, which is pretty simple, but yes in case if lines are separated like how AutoCAD/Rhino handle the lines then finding the point is another problem. – Bear Jan 14 '16 at 16:31