H3C HEALPix library for PostgreSQL  (version 1.2)
h3c_poly_more.c File Reference

other function to deal with polygon More...

#include "common.h"
#include "h3c_util.h"
#include "h3c_math.h"
+ Include dependency graph for h3c_poly_more.c:

Go to the source code of this file.

Functions

void h3c_poly_center (int n, h3c_coord_t *in_ra, h3c_coord_t *in_dec, h3c_coord_t *b)
 get the polgon center More...
 
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 More...
 
int h3c_poly_is_convex (int n, h3c_coord_t *in_ra, h3c_coord_t *in_dec)
 verify if the polygon is convex More...
 
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 More...
 
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 More...
 
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 More...
 
h3c_coord_t h3c_polygon_area (h3c_coord_t *in_ra, h3c_coord_t *in_dec, int n)
 calculate the area of a polygon More...
 

Detailed Description

other function to deal with polygon

Date
05/08/2011
Author
G.Landais

Definition in file h3c_poly_more.c.

Function Documentation

◆ 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

Parameters
n1number of vertex of the 1st polygon
in_ra1right ascention of the point of the 1st polygon
in_dec1declination of the point of the 1st polygon
n2number of vertex of the 1st polygon
in_ra2right ascention of the point of the 1st polygon
in_dec2declination of the point of the 1st polygon
Returns
1 the polygons intersects, else 0

Definition at line 575 of file h3c_poly_more.c.

◆ 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

Parameters
nnumber of vertex
in_rapolygon right ascention
in_decpolygon declination
ra0right ascension of the circle
dec0declination of the circle
radiusradius of the circle
Returns
1 intersect| 0 no

Definition at line 320 of file h3c_poly_more.c.

◆ 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

Parameters
nnumber of points
in_raright ascention of the polygon points
in_decdeclination of the polygon points
ra0right ascention of the point to test
dec0declination of the point to test
Returns
H3C_DISJUNCT not inside

@warn the convex polygons are just a particular case of this ensemble

This function can be applied for polygon more large than convex. (see h3c_poly_is_convex)

Note
  • take care of the sens (ie: the order of the point)
  • algo from F.Ochsenbein

Definition at line 185 of file h3c_poly_more.c.

◆ 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

Parameters
nnumber of points
in_raright ascention of the polygon points
in_decdeclination ot the polygon points
b(OUT) the center

Definition at line 86 of file h3c_poly_more.c.

◆ 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

Parameters
nnumber of points
in_raright ascension of the polygon points
in_decdeclination of the polygon points
Returns
0 no, 1 OK

@warn the convex polygons are just a particular case of this ensemble

In reality the function return true if the function h3c_check_sphere_point_in_poly_convex can be applied to verify if a point is inside the polygon.

Definition at line 220 of file h3c_poly_more.c.

References h3c_check_sphere_point_in_poly_convex(), and h3c_poly_center().

+ Here is the call graph for this function:

◆ 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

Parameters
in_raright ascentions of the points of the polygon
in_decdeclinations of the points of the polygon
nnumberof vertex of the polygon
Returns
the area
Note
  • algo from F.Ochsenbein

Definition at line 649 of file h3c_poly_more.c.

◆ 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

Parameters
raright ascention of the points
decdeclination of the points
nnumber of points
nsidenside level
Returns
the list of couple of ipix {[ipix,ipix],[ipix,ipix],....}, NULL if malloc error (see H3C_DEFAULT_MAX_IPIX)

get the ipix where center is inside the polygon

  • the ipix which the distance between the center and the vertexes < radius (where radius is the max ray of circle arroud ipix for a given nside)

P: the center of ipix vect(OQ) = normalized (vect(OA) ^ vect(OB)) dist = pi/2 - acos(vect(OP).vect(OQ))

Definition at line 426 of file h3c_poly_more.c.

References h3c_log().

+ Here is the call graph for this function: