H3C HEALPix library for PostgreSQL  (version 1.2)
h3c_poly_more.c
Go to the documentation of this file.
1 /*
2  Copyright (C) 2012 Gilles Landais (CDS)
3 
4  Author: Gilles Landais, Strasbourg astronomical Data Center (CDS)
5  Email: gilles.landais@unistra.fr
6 
7  This file is part of H3C.
8 
9  H3C is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13 
14  H3C is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with H3C; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23 
30 #include "common.h"
31 #include "h3c_util.h"
32 #include "h3c_math.h"
33 
34 #if H3C_BOX
35 #include "astropos.h"
36 #endif
37 
38 struct h3c_polygon {
39  int nvertex;
40  h3c_coord_t *ra;
41  h3c_coord_t *dec;
42  _h3c_vector *vect_prod;
43  h3c_coord_t center[2];
44  h3c_coord_t radius; /* Circle that embedeed the polygon */
45  int nside;
46  int order;
47  int nipix;
48  int ninside;
49  int nalloc;
50  h3c_ipix_t *ipix;
51 };
52 
53 /*****************************************************************************/
60 /*****************************************************************************/
61 static void h3c_poly_center_xyz(int n,
62  h3c_coord_t *in_ra,
63  h3c_coord_t *in_dec,
64  _h3c_vector b)
65 {
66  int i;
67  _h3c_vector v;
68  b[0] = b[1] = b[2] = 0.0;
69  for (i = 0; i < n; i++) {
70  h3c_2xyz(in_ra[i], in_dec[i],v);
71  b[0] += v[0];
72  b[1] += v[1];
73  b[2] += v[2];
74  }
75  h3c_normalize(b);
76 }
77 
78 /*****************************************************************************/
85 /*****************************************************************************/
86 void h3c_poly_center(int n,
87  h3c_coord_t *in_ra,
88  h3c_coord_t *in_dec,
89  h3c_coord_t *b)
90 {
91  _h3c_vector v;
92  h3c_poly_center_xyz(n, in_ra, in_dec, v);
93  h3c_2radec(v, b);
94  /*h3c_log(H3C_DEBUG, "h3c_poly_center: (x,y,z)=(%.3f,%.3f,%.3f)=(%.3f,%.3f)",
95  v[0], v[1], v[2], b[0], b[1]);*/
96 }
97 
98 /*****************************************************************************/
107 /*****************************************************************************/
108 static _h3c_vector *h3c_poly_vect_prod (h3c_coord_t *in_ra,
109  h3c_coord_t *in_dec,
110  int n) {
111  int i;
112  _h3c_vector u, v, *vecp, *p, *q = NULL;
113 
114  vecp=(_h3c_vector *)malloc(sizeof(_h3c_vector)*n);
115  for (i = 0; i < n; i++) {
116  if (i > 0) { p = q; q = (p==&u)?&v:&u; }
117  else { p = &u; q = &v; h3c_2xyz(in_ra[0], in_dec[0], *p); }
118  h3c_2xyz(in_ra[(i+1)%n], in_dec[(i+1)%n], *q);
119  h3c_vect_prod(*p, *q, vecp[i]);
120  h3c_normalize(vecp[i]);
121  }
122 
123  return vecp;
124 }
125 
126 /*****************************************************************************/
130 /*****************************************************************************/
131 static int _h3c_check_sphere_point_in_poly_convex(int n,
132  h3c_coord_t *in_ra,
133  h3c_coord_t *in_dec,
134  h3c_coord_t ra0,
135  h3c_coord_t dec0,
136  _h3c_vector *vecp)
137 {
138  double s;
139  int i,direct;
140  _h3c_vector v0, v;
141 
142  /* Verify an invalid point ?*/
143  if (n<3) return(false);
144  h3c_2xyz(ra0, dec0, v0);
145 
146  /* compute the centre */
147  h3c_poly_center_xyz(n, in_ra, in_dec,v);
148 
149  /* compute the orientation */
150  s = h3c_scalar_product(v,vecp[0]);
151  direct = s>=0;
152 
153  for (i = 0; i < n; i++) {
154  s = h3c_scalar_product(v0,vecp[i]);
155  if (direct) {
156  if (s<=0) return H3C_DISJUNCT;
157  }
158  else {
159  if (s>0) return H3C_DISJUNCT;
160  }
161  }
162 
163  return !H3C_DISJUNCT;
164 }
165 
166 /*****************************************************************************/
184 /*****************************************************************************/
186  h3c_coord_t *in_ra,
187  h3c_coord_t *in_dec,
188  h3c_coord_t ra0,
189  h3c_coord_t dec0)
190 {
191  int ret;
192  _h3c_vector *vecp;
193 
194  /* compute the vectoral products */
195  vecp = h3c_poly_vect_prod(in_ra, in_dec, n);
196 
197  /* test the point */
198  ret = _h3c_check_sphere_point_in_poly_convex(n, in_ra, in_dec,
199  ra0, dec0, vecp);
200 
201  free(vecp);
202  return ret;
203 }
204 
205 /*****************************************************************************/
219 /*****************************************************************************/
220 int h3c_poly_is_convex(int n, h3c_coord_t *in_ra, h3c_coord_t *in_dec)
221 {
222  int ret;
223  h3c_coord_t center[2];
224  h3c_poly_center(n, in_ra, in_dec, center);
225  ret = h3c_check_sphere_point_in_poly_convex(n, in_ra, in_dec,
226  center[0], center[1]);
227  return (ret == H3C_DISJUNCT)?0:1;
228 }
229 
230 /*****************************************************************************/
237 /*****************************************************************************/
238 static h3c_ipix_t h3c_ipix2level(h3c_ipix_t ipix, int order_in, int order_out)
239 {
240  int i;
241  if (order_in < order_out) {
242  for (i = 0; i < order_out-order_in; i++)
243  ipix = ipix<<2;
244  return ipix;
245  }
246  else {
247  for (i = 0; i < order_in-order_out; i++)
248  ipix = ipix>>2;
249  return ipix;
250  }
251 }
252 
253 
254 /*****************************************************************************/
262 /*****************************************************************************/
263 static int h3c_sphere_circle_intersect_poly(struct h3c_polygon *polygon,
264  h3c_coord_t ra,
265  h3c_coord_t de,
266  h3c_coord_t radius)
267 {
268  int i;
269  _h3c_vector vp;
270  h3c_coord_t dist, dist2poly=-1;
271 
272  h3c_2xyz(ra, de, vp);
273 
274  /* for each vertex ... */
275  for (i = 0; i < polygon->nvertex; i++) {
276  /* compute the distance */
277 
278 #if 0
279  if (polygon->ra[i] == polygon->ra[(i+1)%polygon->nvertex]) {
280  /*dist = (polygon->dec[i])-de;*/
281  if (ra<0) ra+=360;
282  dist = (polygon->ra[i])-ra;
283  }
284  else {
285  dist = (H3C_PI_2 - acos(h3c_scalar_product(vp, polygon->vect_prod[i])))*H3C_RADEG;
286  }
287 #endif
288  dist = (H3C_PI_2 - acos(h3c_scalar_product(vp, polygon->vect_prod[i])))*H3C_RADEG;
289  if (dist < 0) dist = dist*(-1.);
290  if (dist > radius) continue;
291 
292 #if 1
293  /* Refine the list ???
294  IF the center of the current ipix (ra,de) is not in the circle
295  defined by the center of the polygon with a radius=max(dist(Pi))+r
296  (r=the max size of the ipix)
297  THEN the ipix is outside the polygon
298  */
299  if (dist2poly < 0) dist2poly = h3c_dist(ra, de, polygon->center[0], polygon->center[1]);
300  if (dist2poly <= (polygon->radius+radius)) return 1 ;
301 #else
302  return 1;
303 #endif
304  }
305 
306  return 0;
307 }
308 
309 /*****************************************************************************/
319 /*****************************************************************************/
321  h3c_coord_t in_ra[],
322  h3c_coord_t in_dec[],
323  h3c_coord_t ra0,
324  h3c_coord_t dec0,
325  h3c_coord_t radius)
326 {
327  struct h3c_polygon polygon;
328  int intersect;
329 
330  polygon.ra = in_ra;
331  polygon.dec = in_dec;
332  polygon.nvertex = n;
333 
334  /* compute the vect. product */
335  polygon.vect_prod = h3c_poly_vect_prod(in_ra, in_dec, n);
336 
337  intersect = h3c_sphere_circle_intersect_poly(&polygon, ra0, dec0, radius);
338  free(polygon.vect_prod);
339 
340  return intersect;
341 }
342 
343 /*****************************************************************************/
351 /*****************************************************************************/
352 static int h3c_polygon_ipix_in_upper_order(struct h3c_polygon *polygon,
353  int order,
354  h3c_ipix_t in_ipix)
355 {
356  h3c_ipix_t ipix, ipix_max;
357  h3c_coord_t theta, phi, ra, de, radius;
358  int nside;
359 
360  if (order == polygon->order) {
361  if (polygon->nipix > H3C_DEFAULT_MAX_IPIX) return 0;
362 /* h3c_log(H3C_DEBUG, "ADD (nside %.f) ipix %ld", pow(2, order), in_ipix); */
363  H3C_PUSH(polygon->ipix, polygon->nipix, polygon->nalloc, in_ipix)
364  return 1;
365  }
366 
367  nside = pow(2, order+1);
368  radius = h3c_radius(nside);
369  ipix = h3c_ipix2level(in_ipix, order, order+1);
370  ipix_max = h3c_ipix2level(in_ipix+1, order, order+1);
371 
372 
373  for ( ; ipix < ipix_max; ipix++) {
374  h3c_pix2ang_nest(nside, ipix, &theta, &phi);
375 
376  ra = h3c_phi2ra(phi)*H3C_RADEG;
377  de = h3c_theta2dec(theta)*H3C_RADEG;
378 
379  /* if center is inside polygon => OK */
380  if (_h3c_check_sphere_point_in_poly_convex(polygon->nvertex,
381  polygon->ra,
382  polygon->dec,
383  ra,
384  de,
385  polygon->vect_prod) == 1 ) {
386  h3c_ipix_t m, M;
387  m = h3c_ipix2level(ipix, order+1, polygon->order);
388  M = h3c_ipix2level(ipix+1, order+1, polygon->order);
389 
390  if (polygon->nipix+(M-m) > H3C_DEFAULT_MAX_IPIX) return 0;
391  for ( ;m < M; m++) {
392  H3C_PUSH(polygon->ipix, polygon->nipix, polygon->nalloc, m)
393  polygon->ninside++;
394  }
395  continue;
396  }
397 
398  /* if circle arroud ipix intersects a vertex */
399  if (h3c_sphere_circle_intersect_poly(polygon, ra, de, radius) == 1){
400  if (!h3c_polygon_ipix_in_upper_order(polygon, order+1, ipix))
401  return 0;
402  }
403  }
404 
405  return 1;
406 }
407 
408 /*****************************************************************************/
425 /*****************************************************************************/
426 h3c_ipix_t *h3c_polygon_ipix(h3c_coord_t *in_ra,
427  h3c_coord_t *in_dec,
428  int n,
429  int nside,
430  int *count)
431 {
432 #define H3C_MIN_NSIDE 8
433 
434  int i,order;
435  struct h3c_polygon polygon;
436  h3c_ipix_t ipix, max_ipix;
437 h3c_log(H3C_INFO, "h3c_polygon_ipix nside=%d", nside);
438 
439  max_ipix = h3c_npix(H3C_MIN_NSIDE);
440  order = h3c_order(H3C_MIN_NSIDE);
441 
442  H3C_LIST(polygon.ipix, polygon.nalloc)
443  polygon.nipix = 0;
444  polygon.ninside = 0;
445  polygon.nside = nside;
446  polygon.order = h3c_order(nside);
447  polygon.ra = in_ra;
448  polygon.dec = in_dec;
449  polygon.nvertex = n;
450  polygon.radius = 0.;
451 
452  /* compute the vect. product */
453  polygon.vect_prod = h3c_poly_vect_prod(in_ra, in_dec, n);
454 
455  /* calculate center and radius of circle that circumscribed the polygon */
456  h3c_poly_center(n, in_ra, in_dec, polygon.center);
457  for (i=0; i<n; i++) {
458  h3c_coord_t r = h3c_dist(polygon.center[0], polygon.center[1],
459  in_ra[i], in_dec[i]);
460  if (polygon.radius < r) polygon.radius = r;
461  }
462 
463  /* for each ipix (nside = NSIDE_POLYGON_IDX) */
464  for (ipix = 0; ipix < max_ipix; ipix++) {
465  if (!h3c_polygon_ipix_in_upper_order(&polygon, order, ipix)) {
466  h3c_log(H3C_ERROR, "index needs too much ipix (%d) => abort",
467  H3C_DEFAULT_MAX_IPIX);
468  free(polygon.vect_prod);
469  free(polygon.ipix);
470  return NULL;
471  }
472  }
473 
474  h3c_log(H3C_INFO, "(h3c_polygon_ipix) #ipix=%d (%d inside)",
475  polygon.nipix, polygon.ninside);
476  *count = polygon.nipix;
477  free(polygon.vect_prod);
478  return polygon.ipix;
479 }
480 
481 /*****************************************************************************/
489 /*****************************************************************************/
490 static int h3c_big_circle_intersection(_h3c_vector v1,
491  _h3c_vector v2,
492  h3c_coord_t *ra,
493  h3c_coord_t *dec) {
494  _h3c_vector v;
495  h3c_coord_t out[2];
496 
497  h3c_vect_prod(v1, v2, v);
498  if (v[0] ==0 && v[1] == 0 && v[2] == 0) return 0;
499 
500  h3c_normalize(v);
501  h3c_2radec(v, out);
502 
503  ra[0] = out[0];
504  dec[0] = out[1];
505  dec[1] = dec[0]*(-1);
506  if (ra[0] >= 180) ra[1] = ra[0] - 180;
507  else ra[1] = ra[0] + 180;
508  return 1;
509 }
510 
511 /*****************************************************************************/
522 /*****************************************************************************/
523 static int h3c_point_in_vertex(h3c_coord_t ra, h3c_coord_t dec,
524  h3c_coord_t ra0, h3c_coord_t dec0,
525  h3c_coord_t ra1, h3c_coord_t dec1) {
526  int min, max, i;
527  h3c_coord_t r;
528 
529  if (ra0 == ra1) {
530  if (dec1 > dec0) { min = dec0*3600; max = dec1*3600; }
531  else { min = dec1*3600; max = dec0*3600; }
532  i = dec*3600;
533 
534 /*h3c_log(H3C_INFO," h3c_point_in_vertex min(%d)<=%d<=%d",min,i,max);*/
535  if (min <= i && i <= max) return 1;
536  return 0;
537  }
538 
539  if (ra < 0) ra += 360;
540  if (ra0 < 0) ra0 += 360;
541  if (ra1 < 0) ra1 += 360;
542 
543 
544  r = ra1-ra0; if (r < 0) r = r*(-1);
545  if (r == 180) return -1; /* we don't know! */
546 
547 
548  if (r > 180) {
549  if (ra1 > ra0) { max = ra0*3600; min = (ra1-360)*3600; }
550  else { max = ra1*3600; min = (ra0-360)*3600; }
551  }
552  else {
553  if (ra1 > ra0) { min = ra0*3600; max = ra1*3600; }
554  else { min = ra1*3600; max = ra0*3600; }
555  }
556 
557  i = ra*3600;
558 
559 /*h3c_log(H3C_INFO," h3c_point_in_vertex min(%d)<=%d<=%d",min,i,max);*/
560  if (min <= i && i <= max) return 1;
561  return 0;
562 }
563 
564 /*****************************************************************************/
574 /*****************************************************************************/
576  h3c_coord_t in_ra1[],
577  h3c_coord_t in_dec1[],
578  int n2,
579  h3c_coord_t in_ra2[],
580  h3c_coord_t in_dec2[])
581 {
582  _h3c_vector *vect_prod1, vect_prod2;
583  _h3c_vector va2[n2];
584  h3c_coord_t ra[2], dec[2];
585  int i, j, k;
586 
587  /* compute the vect. product */
588  vect_prod1 = h3c_poly_vect_prod(in_ra1, in_dec1, n1);
589 
590  /* compute the vect. product */
591  h3c_2xyz(in_ra2[0], in_dec2[0], va2[0]);
592  for (i = 0; i < n2; i++) {
593  if (i < n2-1) h3c_2xyz(in_ra2[i+1], in_dec2[i+1], va2[i+1]);
594  h3c_vect_prod(va2[i], va2[(i+1)%n2], vect_prod2);
595  h3c_normalize(vect_prod2);
596 
597  for (j = 0; j < n1; j++) {
598  if ( !h3c_big_circle_intersection(vect_prod2, vect_prod1[j], ra, dec)) {
599  /* the same circle */
600  ra[0] = in_ra1[j]; ra[1] = in_ra1[(j+1)%n1];
601  dec[0] = in_dec1[j]; dec[1] = in_dec1[(j+1)%n1];
602  }
603 /*
604 h3c_log(H3C_INFO, "[(%f,%f);(%f,%f)], [(%f,%f);(%f,%f)], (%f,%f);(%f,%f)",
605 in_ra1[j], in_dec1[j], in_ra1[(j+1)%n1], in_dec1[(j+1)%n1],
606 in_ra2[i], in_dec2[i], in_ra2[(i+1)%n2], in_dec2[(i+1)%n2],
607 ra[0],dec[0],ra[1],dec[1]);*/
608 
609  for (k = 0; k < 2; k++) {
610 #if 0
611  if (h3c_check_sphere_point_in_poly_convex(n2, in_ra2, in_dec2, ra[k], dec[k]) == H3C_DISJUNCT)
612  continue;
613 h3c_log(H3C_INFO, "ok inside poly2");
614  if (h3c_check_sphere_point_in_poly_convex(n1, in_ra1, in_dec1, ra[k], dec[k]) != H3C_DISJUNCT) {
615 h3c_log(H3C_INFO, "ok inside poly1");
616  free(vect_prod1);
617  return 1;
618  }
619 #else
620  if (h3c_point_in_vertex(ra[k], dec[k],
621  in_ra1[j], in_dec1[j],
622  in_ra1[(j+1)%n1], in_dec1[(j+1)%n1]) != 1)
623  continue;
624  if (h3c_point_in_vertex(ra[k], dec[k],
625  in_ra2[i], in_dec2[i],
626  in_ra2[(i+1)%n2], in_dec2[(i+1)%n2]) == 1)
627  return 1;
628 #endif
629 
630  }
631  }
632  }
633 
634  free(vect_prod1);
635  return 0;
636 }
637 
638 /*****************************************************************************/
648 /*****************************************************************************/
649 h3c_coord_t h3c_polygon_area(h3c_coord_t *in_ra,
650  h3c_coord_t *in_dec,
651  int n) {
652  int i;
653  double s;
654  _h3c_vector v1, v2;
655  _h3c_vector *vect = (_h3c_vector *)malloc(sizeof(_h3c_vector)*n);
656 
657  /* compute the cart. coord. */
658  for (i = 0; i < n; i++) h3c_2xyz(in_ra[i], in_dec[i], vect[i]);
659 
660  /* vectorial product */
661  s = (2-n)*180.;
662  h3c_vect_prod(vect[0], vect[n-1], v1); h3c_normalize(v1);
663  h3c_vect_prod(vect[0],vect[1], v2); h3c_normalize(v2);
664  s += 90-asin(h3c_scalar_product(v1, v2))*H3C_RADEG;
665  for (i = 1; i < n; i++) {
666  h3c_vect_prod(vect[i], vect[i-1], v1); h3c_normalize(v1);
667  h3c_vect_prod(vect[i], vect[(i+1)%n], v2); h3c_normalize(v2);
668  s += (90-asin(h3c_scalar_product(v1, v2))*H3C_RADEG);
669  }
670 
671  free(vect);
672  return s*H3C_RADEG;
673 }
674 
675 #if H3C_BOX
676 /*****************************************************************************/
688 /*****************************************************************************/
689 void h3c_box_2_polygon(h3c_coord_t in_ra, h3c_coord_t in_dec,
690  h3c_coord_t width, h3c_coord_t height,
691  h3c_coord_t poly_ra[4], h3c_coord_t poly_dec[4]) {
692  h3c_coord_t R[3][3];
693  h3c_coord_t center[2];
694  h3c_coord_t border[4][2], b[3];
695  int i;
696 
697  center[0] = in_ra; center[1] = in_dec;
698 
699  /* Rotate the center to (0,0) (because problems in pole, ...) */
700  tr_oR(center, R);
701 
702  border[0][0] = tand(-1*width/2.); border[0][1] = tand(-1*height/2.);
703  border[1][0] = -1*border[0][0] ; border[1][1] = border[0][1];
704  border[2][0] = border[1][0] ; border[2][1] = -1*border[0][1];
705  border[3][0] = border[0][0] ; border[3][1] = border[2][1];
706 
707  for (i=0; i<4; i++) {
708  /* projection */
709  tr_pu(_PROJ_TAN_, border[i], b);
710  /* rotation to the original coord */
711  tr_uu1(b, b, R);
712  /* set in polar coordinate */
713  tr_uo(b, border[i]);
714 
715  poly_ra[i] = (border[i][0]<180) ? (h3c_coord_t) border[i][0] : (h3c_coord_t) -1*(360-border[i][0]);
716  poly_dec[i] = (h3c_coord_t) border[i][1];
717  }
718 
719  return;
720 }
721 #else
722 /* This function doesn't work with box using large circle! */
723 void h3c_box_2_polygon(h3c_coord_t in_ra, h3c_coord_t in_dec,
724  h3c_coord_t width, h3c_coord_t height,
725  h3c_coord_t poly_ra[4], h3c_coord_t poly_dec[4]) {
726  poly_ra[0] = in_ra-width/2.; poly_dec[0] = in_dec-height/2.;
727  poly_ra[1] = in_ra+width/2.; poly_dec[1] = poly_dec[0];
728  poly_ra[2] = poly_ra[1] ; poly_dec[2] = in_dec+height/2.;
729  poly_ra[3] = poly_ra[0] ; poly_dec[3] = poly_dec[2];
730 }
731 #endif
h3c_radius
h3c_coord_t h3c_radius(int nside)
get the max radius of ipix for a given nside
Definition: h3c_util.c:204
h3c_log
void h3c_log(int level, char *fmt,...)
print statistics
Definition: h3c_util.c:57
h3c_dist
h3c_coord_t h3c_dist(h3c_coord_t ra1, h3c_coord_t dec1, h3c_coord_t ra2, h3c_coord_t dec2)
calculate the distance between 2 points
Definition: h3c_util.c:460
h3c_theta2dec
h3c_coord_t h3c_theta2dec(h3c_coord_t theta)
get the declination from the theta value
Definition: h3c_util.c:125
h3c_phi2ra
h3c_coord_t h3c_phi2ra(h3c_coord_t phi)
get the right ascension from the phi value
Definition: h3c_util.c:149
h3c_2xyz
void h3c_2xyz(double lon, double lat, _h3c_vector vect)
compute coord in cartesian
Definition: h3c_math.c:39
h3c_2radec
void h3c_2radec(double *in, h3c_coord_t *out)
cartesian to polar
Definition: h3c_math.c:53
h3c_npix
h3c_ipix_t h3c_npix(int nside)
get the number of ipix in the entire sphere
Definition: h3c_util.c:194
h3c_poly_is_convex
int h3c_poly_is_convex(int n, h3c_coord_t *in_ra, h3c_coord_t *in_dec)
verify if the polygon is convex
Definition: h3c_poly_more.c:220
h3c_order
int h3c_order(int nside)
get the order from the nside number
Definition: h3c_util.c:173
h3c_check_sphere_point_in_poly_convex
int h3c_check_sphere_point_in_poly_convex(int n, h3c_coord_t *in_ra, h3c_coord_t *in_dec, h3c_coord_t ra0, h3c_coord_t dec0)
verify if a point is inside a convex polygon
Definition: h3c_poly_more.c:185
h3c_normalize
void h3c_normalize(_h3c_vector u)
normalize in the united vector
Definition: h3c_math.c:101
common.h
h3c_util.h
usefull functions in the library heaplix for PostgreSQL
h3c_check_poly_intersect_poly
int h3c_check_poly_intersect_poly(int n1, h3c_coord_t in_ra1[], h3c_coord_t in_dec1[], int n2, h3c_coord_t in_ra2[], h3c_coord_t in_dec2[])
check if a polygon intersects a vertex of an other polygon
Definition: h3c_poly_more.c:575
h3c_poly_center
void h3c_poly_center(int n, h3c_coord_t *in_ra, h3c_coord_t *in_dec, h3c_coord_t *b)
get the polgon center
Definition: h3c_poly_more.c:86
h3c_check_sphere_circle_intersect_poly
int h3c_check_sphere_circle_intersect_poly(int n, h3c_coord_t in_ra[], h3c_coord_t in_dec[], h3c_coord_t ra0, h3c_coord_t dec0, h3c_coord_t radius)
check if a circle intersects a vertex of a polygon
Definition: h3c_poly_more.c:320
h3c_scalar_product
double h3c_scalar_product(_h3c_vector v1, _h3c_vector v2)
scalar product
Definition: h3c_math.c:92
h3c_polygon_ipix
h3c_ipix_t * h3c_polygon_ipix(h3c_coord_t *in_ra, h3c_coord_t *in_dec, int n, int nside, int *count)
retrieve the ipix list for a polygon
Definition: h3c_poly_more.c:426
h3c_polygon_area
h3c_coord_t h3c_polygon_area(h3c_coord_t *in_ra, h3c_coord_t *in_dec, int n)
calculate the area of a polygon
Definition: h3c_poly_more.c:649
h3c_vect_prod
void h3c_vect_prod(_h3c_vector v1, _h3c_vector v2, _h3c_vector r)
vectorial product
Definition: h3c_math.c:79
h3c_math.h
mathematique functions