[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[task #15578] Function to find if polygon vertices are sorted anti-clock
From: |
Mohammad Akhlaghi |
Subject: |
[task #15578] Function to find if polygon vertices are sorted anti-clockwise |
Date: |
Thu, 26 Mar 2020 14:46:59 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0 |
Follow-up Comment #13, task #15578 (project gnuastro):
Some small points:
* I see that the returned type of the declaration of
`gal_polygon_to_counterclockwise' is still `void', but it has been fixed in
the definition. Do you try compiling these? There should have been a
compilation warning. Note that in Gnuastro, we aim to have no compilation
warnings ;-).
* To help in readability (this is just stylistic), I usually write these
statements like below (so the `sum' conditions are right under each other and
more clear to the eye.
if (sum <0) return GAL_POLYGON_ORIENTATION_CCW;
else if (sum==0) return GAL_POLYGON_ORIENTATION_COMPLEX;
else return GAL_POLYGON_ORIENTATION_CW;
But even a cleaner implementation would be like this, avoiding all the dirty
`if's and `else's and `returns':
return ( sum
? ( sum < 0
? GAL_POLYGON_ORIENTATION_CCW
: GAL_POLYGON_ORIENTATION_CW )
: GAL_POLYGON_ORIENTATION_COMPLEX );
* Given that the natural sign of `sum' is negative when the orientation is
counter-clockwise, it may be better and more clear if the values of
`GAL_POLYGON_ORIENTATION_CCW' and `GAL_POLYGON_ORIENTATION_CW' are
interchanged so they are natural.
After these changes, I think it is good enough for testing. Please correct the
documentation.
Then add a test usage of these library functions in the Crop program (just
before the line `if(crp->p->polygonnosort)' in `polygonmask' of `onecrop.c'):
with a few checking `printf's after it, followed by an `exit 0;'.
Then please add a few example calls to the `--polygon' option in
`tests/during-dev.sh' and commit/push it so I can also try them easily.
The basic idea is that the newly added `polygonnosort' option should be
reversed (replaced): we should be able to automatically see if the given
polygon is sorted or not. If it is, we won't change/touch it. If it isn't
we'll sort it. But the user can manually request a sorting with a new
`--polygonsort' option, in which case, we won't do any sorting checks at all,
and will directly call the `gal_polygon_ordered_corners'.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/task/?15578>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, (continued)
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Mohammad Akhlaghi, 2020/03/22
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Sachin Kumar Singh, 2020/03/23
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Sachin Kumar Singh, 2020/03/23
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Mohammad Akhlaghi, 2020/03/23
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Mohammad Akhlaghi, 2020/03/23
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Sachin Kumar Singh, 2020/03/24
- Message not available
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Sachin Kumar Singh, 2020/03/25
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Mohammad Akhlaghi, 2020/03/25
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Sachin Kumar Singh, 2020/03/25
- Message not available
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Sachin Kumar Singh, 2020/03/26
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise,
Mohammad Akhlaghi <=
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Sachin Kumar Singh, 2020/03/28
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Sachin Kumar Singh, 2020/03/28
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Mohammad Akhlaghi, 2020/03/28
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Sachin Kumar Singh, 2020/03/28
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Mohammad Akhlaghi, 2020/03/28
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Sachin Kumar Singh, 2020/03/28
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Mohammad Akhlaghi, 2020/03/28
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Sachin Kumar Singh, 2020/03/29
- [task #15578] Function to find if polygon vertices are sorted anti-clockwise, Mohammad Akhlaghi, 2020/03/29