1 /********************************************************************* 2 Polygon related functions and macros. 3 This is part of GNU Astronomy Utilities (Gnuastro) package. 4 5 Original author: 6 Mohammad Akhlaghi <mohammad@akhlaghi.org> 7 Contributing author(s): 8 Sachin Kumar Singh <sachinkumarsingh092@gmail.com> 9 Copyright (C) 2015-2021, Free Software Foundation, Inc. 10 11 Gnuastro is free software: you can redistribute it and/or modify it 12 under the terms of the GNU General Public License as published by the 13 Free Software Foundation, either version 3 of the License, or (at your 14 option) any later version. 15 16 Gnuastro is distributed in the hope that it will be useful, but 17 WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 General Public License for more details. 20 21 You should have received a copy of the GNU General Public License 22 along with Gnuastro. If not, see <http://www.gnu.org/licenses/>. 23 **********************************************************************/ 24 #ifndef __GAL_POLYGON_H__ 25 #define __GAL_POLYGON_H__ 26 27 /* Include other headers if necessary here. Note that other header files 28 must be included before the C++ preparations below */ 29 30 31 32 /* C++ Preparations */ 33 #undef __BEGIN_C_DECLS 34 #undef __END_C_DECLS 35 #ifdef __cplusplus 36 # define __BEGIN_C_DECLS extern "C" { 37 # define __END_C_DECLS } 38 #else 39 # define __BEGIN_C_DECLS /* empty */ 40 # define __END_C_DECLS /* empty */ 41 #endif 42 /* End of C++ preparations */ 43 44 45 46 /* Actual header contants (the above were for the Pre-processor). */ 47 __BEGIN_C_DECLS /* From C++ preparations */ 48 49 50 51 #define GAL_POLYGON_MAX_CORNERS 50 52 #define GAL_POLYGON_ROUND_ERR 1e-5 53 54 55 56 57 58 /***************************************************************/ 59 /************** Function declarations ******************/ 60 /***************************************************************/ 61 void 62 gal_polygon_vertices_sort_convex(double *in, size_t n, size_t *ordinds); 63 64 int 65 gal_polygon_is_convex(double *v, size_t n); 66 67 double 68 gal_polygon_area(double *v, size_t n); 69 70 int 71 gal_polygon_is_inside(double *v, double *p, size_t n); 72 73 int 74 gal_polygon_is_inside_convex(double *v, double *p, size_t n); 75 76 int 77 gal_polygon_ppropin(double *v, double *p, size_t n); 78 79 int 80 gal_polygon_is_counterclockwise(double *v, size_t n); 81 82 int 83 gal_polygon_to_counterclockwise(double *v, size_t n); 84 85 void 86 gal_polygon_clip(double *s, size_t n, double *c, size_t m, 87 double *o, size_t *numcrn); 88 89 void 90 gal_polygon_vertices_sort(double *in, size_t n, size_t *ordinds); 91 92 __END_C_DECLS /* From C++ preparations */ 93 94 #endif /* __GAL_POLYGON_H__ */ 95