/misc/src/release/graphviz-2.18-1/src/graphviz-2.18/lib/common/arith.h

Go to the documentation of this file.
00001 /* $Id: arith.h,v 1.10 2008/03/03 23:01:51 ellson Exp $ $Revision: 1.10 $ */
00002 /* vim:set shiftwidth=4 ts=8: */
00003 
00004 /**********************************************************
00005 *      This software is part of the graphviz package      *
00006 *                http://www.graphviz.org/                 *
00007 *                                                         *
00008 *            Copyright (c) 1994-2004 AT&T Corp.           *
00009 *                and is licensed under the                *
00010 *            Common Public License, Version 1.0           *
00011 *                      by AT&T Corp.                      *
00012 *                                                         *
00013 *        Information and Software Systems Research        *
00014 *              AT&T Research, Florham Park NJ             *
00015 **********************************************************/
00016 
00017 /* geometric functions (e.g. on points and boxes) with application to, but
00018  * no specific dependance on graphs */
00019 
00020 #ifndef GV_ARITH_H
00021 #define GV_ARITH_H
00022 
00023 /* for sincos */
00024 #ifndef _GNU_SOURCE
00025 #define _GNU_SOURCE 1
00026 #endif
00027 #ifdef HAVE_LIMITS_H
00028 #include <limits.h>
00029 #else
00030 #ifdef HAVE_VALUES_H
00031 #include <values.h>
00032 #endif
00033 #endif
00034 #include <math.h>
00035 
00036 #ifdef __cplusplus
00037 extern "C" {
00038 #endif
00039 
00040 #ifdef MIN
00041 #undef MIN
00042 #endif
00043 #define MIN(a,b)        ((a)<(b)?(a):(b))
00044 
00045 #ifdef MAX
00046 #undef MAX
00047 #endif
00048 #define MAX(a,b)        ((a)>(b)?(a):(b))
00049 
00050 #ifdef ABS
00051 #undef ABS
00052 #endif
00053 #define ABS(a)          ((a) >= 0 ? (a) : -(a))
00054 
00055 #ifndef INT_MAX
00056 #define INT_MAX         ((int)(~(unsigned)0 >> 1))
00057 #endif
00058 
00059 #ifndef INT_MIN
00060 #define INT_MIN         (-INT_MAX - 1)
00061 #endif
00062 
00063 #ifndef MAXSHORT
00064 #define MAXSHORT        (0x7fff)
00065 #endif
00066 
00067 #ifndef MAXDOUBLE
00068 #define MAXDOUBLE       1.7976931348623157e+308
00069 #endif
00070 
00071 #ifndef MAXFLOAT
00072 #define MAXFLOAT        ((float)3.40282347e+38)
00073 #endif
00074 
00075 #ifdef BETWEEN
00076 #undef BETWEEN
00077 #endif
00078 #define BETWEEN(a,b,c)  (((a) <= (b)) && ((b) <= (c)))
00079 
00080 #ifndef M_PI
00081 #define M_PI            3.14159265358979323846
00082 #endif
00083 
00084 #ifndef SQRT2
00085 #define SQRT2           1.41421356237309504880
00086 #endif
00087 
00088 #define ROUND(f)        ((f>=0)?(int)(f + .5):(int)(f - .5))
00089 #define RADIANS(deg)    ((deg)/180.0 * M_PI)
00090 #define DEGREES(rad)    ((rad)/M_PI * 180.0)
00091 
00092 #define SQR(a) ((a) * (a))
00093 
00094 #ifdef HAVE_SINCOS
00095     extern void sincos(double x, double *s, double *c);
00096 #else
00097 # define sincos(x,s,c) *s = sin(x); *c = cos(x)
00098 #endif
00099 
00100 #ifdef __cplusplus
00101 }
00102 #endif
00103 
00104 #endif

Generated on Mon Mar 31 19:03:23 2008 for Graphviz by  doxygen 1.5.1