wolffd@0: /* $Id: arith.h,v 1.16 2009/06/03 01:10:51 ellson Exp $ $Revision: 1.16 $ */ wolffd@0: /* vim:set shiftwidth=4 ts=8: */ wolffd@0: wolffd@0: /********************************************************** wolffd@0: * This software is part of the graphviz package * wolffd@0: * http://www.graphviz.org/ * wolffd@0: * * wolffd@0: * Copyright (c) 1994-2004 AT&T Corp. * wolffd@0: * and is licensed under the * wolffd@0: * Common Public License, Version 1.0 * wolffd@0: * by AT&T Corp. * wolffd@0: * * wolffd@0: * Information and Software Systems Research * wolffd@0: * AT&T Research, Florham Park NJ * wolffd@0: **********************************************************/ wolffd@0: wolffd@0: /* geometric functions (e.g. on points and boxes) with application to, but wolffd@0: * no specific dependance on graphs */ wolffd@0: wolffd@0: #ifndef GV_ARITH_H wolffd@0: #define GV_ARITH_H wolffd@0: wolffd@0: /* for sincos */ wolffd@0: #ifndef _GNU_SOURCE wolffd@0: #define _GNU_SOURCE 1 wolffd@0: #endif wolffd@0: wolffd@0: #include wolffd@0: #ifdef HAVE_VALUES_H wolffd@0: #include wolffd@0: #endif wolffd@0: #include wolffd@0: wolffd@0: #ifdef __cplusplus wolffd@0: extern "C" { wolffd@0: #endif wolffd@0: wolffd@0: #ifdef MIN wolffd@0: #undef MIN wolffd@0: #endif wolffd@0: #define MIN(a,b) ((a)<(b)?(a):(b)) wolffd@0: wolffd@0: #ifdef MAX wolffd@0: #undef MAX wolffd@0: #endif wolffd@0: #define MAX(a,b) ((a)>(b)?(a):(b)) wolffd@0: wolffd@0: #ifdef ABS wolffd@0: #undef ABS wolffd@0: #endif wolffd@0: #define ABS(a) ((a) >= 0 ? (a) : -(a)) wolffd@0: wolffd@0: #define AVG(a,b) ((a + b) / 2) wolffd@0: #define SGN(a) (((a)<0)? -1 : 1) wolffd@0: #define CMP(a,b) (((a)<(b)) ? -1 : (((a)>(b)) ? 1 : 0)) wolffd@0: wolffd@0: #ifndef INT_MAX wolffd@0: #define INT_MAX ((int)(~(unsigned)0 >> 1)) wolffd@0: #endif wolffd@0: wolffd@0: #ifndef INT_MIN wolffd@0: #define INT_MIN (-INT_MAX - 1) wolffd@0: #endif wolffd@0: wolffd@0: #ifndef MAXSHORT wolffd@0: #define MAXSHORT (0x7fff) wolffd@0: #endif wolffd@0: wolffd@0: #ifndef MAXDOUBLE wolffd@0: #define MAXDOUBLE 1.7976931348623157e+308 wolffd@0: #endif wolffd@0: wolffd@0: #ifndef MAXFLOAT wolffd@0: #define MAXFLOAT ((float)3.40282347e+38) wolffd@0: #endif wolffd@0: wolffd@0: #ifdef BETWEEN wolffd@0: #undef BETWEEN wolffd@0: #endif wolffd@0: #define BETWEEN(a,b,c) (((a) <= (b)) && ((b) <= (c))) wolffd@0: wolffd@0: #ifndef M_PI wolffd@0: #define M_PI 3.14159265358979323846 wolffd@0: #endif wolffd@0: wolffd@0: #ifndef SQRT2 wolffd@0: #define SQRT2 1.41421356237309504880 wolffd@0: #endif wolffd@0: wolffd@0: #define ROUND(f) ((f>=0)?(int)(f + .5):(int)(f - .5)) wolffd@0: #define RADIANS(deg) ((deg)/180.0 * M_PI) wolffd@0: #define DEGREES(rad) ((rad)/M_PI * 180.0) wolffd@0: wolffd@0: #define SQR(a) ((a) * (a)) wolffd@0: wolffd@0: #ifdef HAVE_SINCOS wolffd@0: extern void sincos(double x, double *s, double *c); wolffd@0: #else wolffd@0: # define sincos(x,s,c) *s = sin(x); *c = cos(x) wolffd@0: #endif wolffd@0: wolffd@0: #ifdef __cplusplus wolffd@0: } wolffd@0: #endif wolffd@0: wolffd@0: #endif