GNU Astronomy Utilities


Next: , Previous: , Up: Gnuastro library   [Contents][Index]


10.3.16 Bounding box (box.h)

Functions related to reporting a the bounding box of certain inputs are declared in gnuastro/box.h. All coordinates in this header are in the FITS format (first axis is the horizontal and the second axis is vertical).

Function:
void
gal_box_bound_ellipse_extent (double a, double b, double theta_deg, double *extent)

Return the maximum extent along each dimension of the given ellipse from the center of the ellipse. Therefore this is half the extent of the box in each dimension. a is the ellipse semi-major axis, b is the semi-minor axis, theta_deg is the position angle in degrees. The extent in each dimension is in floating point format and stored in extent which must already be allocated before this function.

Function:
void
gal_box_bound_ellipse (double a, double b, double theta_deg, long *width)

Any ellipse can be enclosed into a rectangular box. This function will write the height and width of that box where width points to. It assumes the center of the ellipse is located within the central pixel of the box. a is the ellipse semi-major axis length, b is the semi-minor axis, theta_deg is the position angle in degrees. The width array will contain the output size in long integer type. width[0], and width[1] are the number of pixels along the first and second FITS axis. Since the ellipse center is assumed to be in the center of the box, all the values in width will be an odd integer.

Function:
void
gal_box_border_from_center (double center, size_t ndim, long *width, long *fpixel, long *lpixel)

Given the center coordinates in center and the width (along each dimension) of a box, return the coordinates of the first (fpixel) and last (lpixel) pixels. All arrays must have ndim elements (one for each dimension).

Function:
int
gal_box_overlap (long *naxes, long *fpixel_i, long *lpixel_i, long *fpixel_o, long *lpixel_o, size_t ndim)

An ndim-dimensional dataset of size naxes (along each dimension, in FITS order) and a box with first and last (inclusive) coordinate of fpixel_i and lpixel_i is given. This box doesn’t necessarily have to lie within the dataset, it can be outside of it, or only partially overlap. This function will change the values of fpixel_i and lpixel_i to exactly cover the overlap in the input dataset’s coordinates.

This function will return 1 if there is an overlap and 0 if there isn’t. When there is an overlap, the coordinates of the first and last pixels of the overlap will be put in fpixel_o and lpixel_o.


Next: , Previous: , Up: Gnuastro library   [Contents][Index]