File: rowcol.h

package info (click to toggle)
grass 6.4.4-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 104,028 kB
  • ctags: 40,409
  • sloc: ansic: 419,980; python: 63,559; tcl: 46,692; cpp: 29,791; sh: 18,564; makefile: 7,000; xml: 3,505; yacc: 561; perl: 559; lex: 480; sed: 70; objc: 7
file content (40 lines) | stat: -rw-r--r-- 1,379 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef _ROWCOL_H
#define _ROWCOL_H

/* these defines work with modeling coordinates only */

/* view resolutions */
#define VXRES(gs)   (gs->x_mod * gs->xres)
#define VYRES(gs)   (gs->y_mod * gs->yres)

/* number of viewres rows/cols */
#define VROWS(gs)    (int)((gs->rows -1)/gs->y_mod)
#define VCOLS(gs)    (int)((gs->cols -1)/gs->x_mod)

/* data row & col to offset */
#define DRC2OFF(gs, drow, dcol)  (int)((dcol) + (drow) * gs->cols)

/* ycoord/xcoord to data row/col */
#define Y2DROW(gs,py)      (int)((gs->yrange - (py))/gs->yres)
#define X2DCOL(gs,px)      (int)((px)/gs->xres)

/* ycoord/xcoord to offset */
#define XY2OFF(gs, px, py) (int)DRC2OFF(gs, Y2DROW(gs,py), X2DCOL(gs,px))

/* ycoord/xcoord to viewres row/col */
#define Y2VROW(gs,py)      (int)((gs->yrange - (py))/(gs->yres * gs->y_mod))
#define X2VCOL(gs,px)      (int)((px)/(gs->xres * gs->x_mod))

/* viewres row/col to data row/col */
#define VROW2DROW(gs,vrow)      (int)(gs->y_mod * (vrow))
#define VCOL2DCOL(gs,vcol)      (int)(gs->x_mod * (vcol))

/* data row/col to ycoord/xcoord */
#define DROW2Y(gs,drow)      (gs->yrange - ((drow) * gs->yres))
#define DCOL2X(gs,dcol)      ((dcol) * gs->xres)

/* viewres row/col to ycoord/xcoord */
#define VROW2Y(gs,vrow)      (gs->yrange - ((vrow) * gs->yres * gs->y_mod))
#define VCOL2X(gs,vcol)      ((vcol) * gs->xres * gs->x_mod)

#endif /* _ROWCOL_H */