GRASS Programmer's Manual  6.4.2(2012)
rowcol.h
Go to the documentation of this file.
00001 #ifndef _ROWCOL_H
00002 #define _ROWCOL_H
00003 
00004 /* these defines work with modeling coordinates only */
00005 
00006 /* view resolutions */
00007 #define VXRES(gs)   (gs->x_mod * gs->xres)
00008 #define VYRES(gs)   (gs->y_mod * gs->yres)
00009 
00010 /* number of viewres rows/cols */
00011 #define VROWS(gs)    (int)((gs->rows -1)/gs->y_mod)
00012 #define VCOLS(gs)    (int)((gs->cols -1)/gs->x_mod)
00013 
00014 /* data row & col to offset */
00015 #define DRC2OFF(gs, drow, dcol)  (int)((dcol) + (drow) * gs->cols)
00016 
00017 /* ycoord/xcoord to data row/col */
00018 #define Y2DROW(gs,py)      (int)((gs->yrange - (py))/gs->yres)
00019 #define X2DCOL(gs,px)      (int)((px)/gs->xres)
00020 
00021 /* ycoord/xcoord to offset */
00022 #define XY2OFF(gs, px, py) (int)DRC2OFF(gs, Y2DROW(gs,py), X2DCOL(gs,px))
00023 
00024 /* ycoord/xcoord to viewres row/col */
00025 #define Y2VROW(gs,py)      (int)((gs->yrange - (py))/(gs->yres * gs->y_mod))
00026 #define X2VCOL(gs,px)      (int)((px)/(gs->xres * gs->x_mod))
00027 
00028 /* viewres row/col to data row/col */
00029 #define VROW2DROW(gs,vrow)      (int)(gs->y_mod * (vrow))
00030 #define VCOL2DCOL(gs,vcol)      (int)(gs->x_mod * (vcol))
00031 
00032 /* data row/col to ycoord/xcoord */
00033 #define DROW2Y(gs,drow)      (gs->yrange - ((drow) * gs->yres))
00034 #define DCOL2X(gs,dcol)      ((dcol) * gs->xres)
00035 
00036 /* viewres row/col to ycoord/xcoord */
00037 #define VROW2Y(gs,vrow)      (gs->yrange - ((vrow) * gs->yres * gs->y_mod))
00038 #define VCOL2X(gs,vcol)      ((vcol) * gs->xres * gs->x_mod)
00039 
00040 #endif /* _ROWCOL_H */
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines