gnuastro-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[task #13658] Work on concave polygons too


From: Sachin Kumar Singh
Subject: [task #13658] Work on concave polygons too
Date: Thu, 12 Mar 2020 17:35:24 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:73.0) Gecko/20100101 Firefox/73.0

Follow-up Comment #9, task #13658 (project gnuastro):

The program to sort the concave polygons is ready. It is still a crude code to
be modified when importing to the library. 
I've used a different algorithm which uses a diagonal vector between the
rightmost and leftmost point. Then this vector is used to group the points
which are above and below it. 
Now consider each segment in the output polygon. The first edge from the
leftmost point to the first point in A can't intersect any segment (because
there is no segment yet). As we proceed in order by x-coordinate through the
points in A, from each point, the next segment is going to the right, and all
previous segments are to the left. Thus, as we go from the leftmost point,
through all the points of A, to the rightmost point, we will have no
intersections. This guarantees that no intersection of point or edges will
take place. The same can be argued for B in descending order. 
Then we sort both the arrays based on their x-coordinate, the point above and
on the vector in ascending order and the point below in descending order. 
Finally merging these two arrays gives an output array in the desired sorted
format.

I've tested this code and it works well. But there is still a minor problem
when I try to use the sizes of the temporary arrays as global variables. The
problem and its temporary workaround is commented in the code. Please suggest
some way to remove this bug. Apart from the bug, I think we need to just
beautify the code before exporting it to the gal library. 

(file #48589)
    _______________________________________________________

Additional Item Attachment:

File name: test.c                         Size:4 KB
    <https://savannah.gnu.org/file/test.c?file_id=48589>



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/task/?13658>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]