H3C HEALPix library for PostgreSQL  (version 1.2)
h3c_util.h File Reference

usefull functions in the library heaplix for PostgreSQL More...

+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void h3c_debug_init_clock ()
 initalize the debugger timer
 
void h3c_log (int level, char *fmt,...)
 print statistics More...
 
h3c_coord_t h3c_theta2dec (h3c_coord_t)
 get the declination from the theta value More...
 
h3c_coord_t h3c_dec2theta (h3c_coord_t)
 get the theta value from the declination More...
 
h3c_coord_t h3c_phi2ra (h3c_coord_t)
 get the right ascension from the phi value More...
 
h3c_coord_t h3c_ra2phi (h3c_coord_t)
 get the phi value from the right ascension More...
 
int h3c_order (int nside)
 get the order from the nside number More...
 
h3c_ipix_t h3c_npix (int nside)
 get the number of ipix in the entire sphere More...
 
h3c_coord_t h3c_radius (int nside)
 get the max radius of ipix for a given nside More...
 
h3c_ipix_t * h3c_disk_ipix (h3c_coord_t, h3c_coord_t, h3c_coord_t, int, int *)
 (c++ interface) get the ipix list of a cone More...
 
h3c_coord_t h3c_dist (h3c_coord_t, h3c_coord_t, h3c_coord_t, h3c_coord_t)
 calculate the distance between 2 points More...
 
h3c_coord_t h3c_sindist (h3c_coord_t, h3c_coord_t, h3c_coord_t, h3c_coord_t)
 calculate the sinus distance (to be compatible with Q3C) More...
 
h3c_ipix_t * h3c_polygon_ipix (h3c_coord_t *, h3c_coord_t *, int, int, int *)
 retrieve the ipix list for a polygon More...
 
char h3c_in_ellipse (h3c_coord_t, h3c_coord_t, h3c_coord_t, h3c_coord_t, h3c_coord_t, h3c_coord_t, h3c_coord_t)
 verify if a point is inside an ellipse More...
 
int h3c_poly_is_convex (int n, h3c_coord_t *, h3c_coord_t *)
 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...
 
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

usefull functions in the library heaplix for PostgreSQL

Author
G.Landais (CDS)
Date
19/jul/2011
Note
this file contains __cplusplus macro to be used with C and C++

Definition in file h3c_util.h.

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_dec2theta()

h3c_coord_t h3c_dec2theta ( h3c_coord_t  dec)

get the theta value from the declination

Parameters
decdeclination
Returns
theta

Definition at line 136 of file h3c_util.c.

◆ h3c_disk_ipix()

h3c_ipix_t* h3c_disk_ipix ( h3c_coord_t  ra,
h3c_coord_t  dec,
h3c_coord_t  radius,
int  nside,
int *  count 
)

(c++ interface) get the ipix list of a cone

Parameters
raright ascension
decdeclination
radiusradius of the cone
nsidenside level
Returns
ipix list

Definition at line 225 of file h3c_util.c.

References h3cpp_disk_ipix().

+ Here is the call graph for this function:

◆ 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

Parameters
ra1right ascention of the first point
dec1declination of the first point
ra2right ascention of the second point
dec2declination of the second point
Returns
the distance
Note
Use the haversine function

Definition at line 460 of file h3c_util.c.

◆ h3c_in_ellipse()

char h3c_in_ellipse ( h3c_coord_t  alpha,
h3c_coord_t  delta0,
h3c_coord_t  alpha1,
h3c_coord_t  delta01,
h3c_coord_t  d0,
h3c_coord_t  e,
h3c_coord_t  PA0 
)

verify if a point is inside an ellipse

Note
: code coming from Q3C

Definition at line 615 of file h3c_util.c.

◆ h3c_log()

void h3c_log ( int  level,
char *  fmt,
  ... 
)

print statistics

Parameters
levelINFO
fmtformat
...optional argument used in format

Definition at line 57 of file h3c_util.c.

◆ h3c_npix()

h3c_ipix_t h3c_npix ( int  nside)

get the number of ipix in the entire sphere

Parameters
nsidenside level
Returns
number of ipix in the entire sphere

Definition at line 194 of file h3c_util.c.

◆ h3c_order()

int h3c_order ( int  nside)

get the order from the nside number

Parameters
nsidenside level
Returns
the order

Definition at line 173 of file h3c_util.c.

References h3c_log().

+ Here is the call graph for this function:

◆ h3c_phi2ra()

h3c_coord_t h3c_phi2ra ( h3c_coord_t  phi)

get the right ascension from the phi value

Parameters
phi
Returns
right ascension

Definition at line 149 of file h3c_util.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:

◆ h3c_ra2phi()

h3c_coord_t h3c_ra2phi ( h3c_coord_t  ra)

get the phi value from the right ascension

Parameters
raright ascension
Returns
phi

Definition at line 161 of file h3c_util.c.

◆ h3c_radius()

h3c_coord_t h3c_radius ( int  nside)

get the max radius of ipix for a given nside

Parameters
nsidenside level
Returns
the radius

Definition at line 204 of file h3c_util.c.

◆ h3c_sindist()

h3c_coord_t h3c_sindist ( h3c_coord_t  ra1,
h3c_coord_t  dec1,
h3c_coord_t  ra2,
h3c_coord_t  dec2 
)

calculate the sinus distance (to be compatible with Q3C)

Parameters
ra1right ascention of the first point
dec1declination of the first point
ra2right ascention of the second point
dec2declination of the second point
Returns
the distance
Note
Use the haversine function

Definition at line 486 of file h3c_util.c.

◆ h3c_theta2dec()

h3c_coord_t h3c_theta2dec ( h3c_coord_t  theta)

get the declination from the theta value

Parameters
theta
Returns
declination

Definition at line 125 of file h3c_util.c.