home *** CD-ROM | disk | FTP | other *** search
-
- #define GK_FLOOR(x) ((x) > 0 ? (int)(x) : -(int)(-(x)))
- #define GK_CEILING(x) ((x) == (int)(x) ? (x) : (x) > 0 ? \
- 1 + (int)(x) : -(1 + (int)(-(x))))
- #define GK_ROUND(x) ((x) > 0 ? (int)((x) + 0.5) : -(int)(0.5 - (x)))
-
- // SIGN() macros: ZERO returns 0 for x==0, BINARY returns 1 for x >= 0
- #define GK_ZERO_SIGN(x) ((x) < 0 ? -1 : (x) > 0 ? 1 : 0)
- #define GK_BINARY_SIGN(x) ((x) < 0 ? -1 : 1)
-
- #define GK_SQUARE(x) ((x) * (x))
-
- // use this to swap two variables (exprs won't work, obviously)
- #define GK_SWAP(a, b) { a^=b; b^=a; a^=b; }
-
- // "clamp" a variable (v) to a range (keep it within l to h)
- #define GK_CLAMP(v, l, h) ((v) < (l) ? (l) : (v) > (h) ? (h) : (v))
-
- #define GK_KEYS_ARE_SAME(a, b) (((a)->data.key.charCode == \
- (b)->data.key.charCode) && ((a)->data.key.charSet == \
- (b)->data.key.charSet))
-
- #define GK_RADIUS(x) ((x)->radius) // x must be GKCircle type!
- #define GK_CENTER(x) (&((x)->center)) // x must be GKCircle type!
- #define GK_CENTER_X(a) ((a)->center.x) // x must be GKCircle type!
- #define GK_CENTER_Y(a) ((a)->center.y) // x must be GKCircle type!
- #define GK_VERTEX(x, n) (&((x)->points[(n)])) // x must be GKTriangle type!
-
- // manipulate vectors; use a pointer to the appropriate vector
- #define GK_NONZERO_VECTOR(a) (((a)->x != 0.0) || ((a)->y != 0.0))
- #define GK_SET_VECTOR(a, b, c) (a)->x = (b); (a)->y = (c)
- #define GK_ADD_VECTORS(a, b) (a)->x += (b)->x; (a)->y += (b)->y
- #define GK_COPY_VECTORS(a, b) (a)->x = (b)->x; (a)->y = (b)->y
- #define GK_CLEAR_VECTOR(a) (a)->x = 0; (a)->y = 0
- #define GK_VECTOR_X(a) (a)->x
- #define GK_VECTOR_Y(a) (a)->y
- #define GK_COPY_SIZES(a, b) (a)->width = (b)->width; \
- (a)->height = (b)->height
- #define GK_COPY_RECT(a, b) NX_X(a) = NX_X(b); NX_Y(a) = NX_Y(b); \
- NX_WIDTH(a) = NX_WIDTH(b); NX_HEIGHT(a) = NX_HEIGHT(b);
-
-