|
Graphviz 2.29.20120208.0545
|
00001 /* $Id$ $Revision$ */ 00002 /* vim:set shiftwidth=4 ts=8: */ 00003 00004 /************************************************************************* 00005 * Copyright (c) 2011 AT&T Intellectual Property 00006 * All rights reserved. This program and the accompanying materials 00007 * are made available under the terms of the Eclipse Public License v1.0 00008 * which accompanies this distribution, and is available at 00009 * http://www.eclipse.org/legal/epl-v10.html 00010 * 00011 * Contributors: See CVS logs. Details at http://www.graphviz.org/ 00012 *************************************************************************/ 00013 00014 /* geometric functions (e.g. on points and boxes) with application to, but 00015 * no specific dependance on graphs */ 00016 00017 #ifndef GV_ARITH_H 00018 #define GV_ARITH_H 00019 00020 /* for sincos */ 00021 #ifndef _GNU_SOURCE 00022 #define _GNU_SOURCE 1 00023 #endif 00024 00025 #include <limits.h> 00026 #ifdef HAVE_VALUES_H 00027 #include <values.h> 00028 #endif 00029 #include <math.h> 00030 00031 #ifdef __cplusplus 00032 extern "C" { 00033 #endif 00034 00035 #ifdef MIN 00036 #undef MIN 00037 #endif 00038 #define MIN(a,b) ((a)<(b)?(a):(b)) 00039 00040 #ifdef MAX 00041 #undef MAX 00042 #endif 00043 #define MAX(a,b) ((a)>(b)?(a):(b)) 00044 00045 #ifdef ABS 00046 #undef ABS 00047 #endif 00048 #define ABS(a) ((a) >= 0 ? (a) : -(a)) 00049 00050 #define AVG(a,b) ((a + b) / 2) 00051 #define SGN(a) (((a)<0)? -1 : 1) 00052 #define CMP(a,b) (((a)<(b)) ? -1 : (((a)>(b)) ? 1 : 0)) 00053 00054 #ifndef INT_MAX 00055 #define INT_MAX ((int)(~(unsigned)0 >> 1)) 00056 #endif 00057 00058 #ifndef INT_MIN 00059 #define INT_MIN (-INT_MAX - 1) 00060 #endif 00061 00062 #ifndef MAXSHORT 00063 #define MAXSHORT (0x7fff) 00064 #endif 00065 00066 #ifndef MAXDOUBLE 00067 #define MAXDOUBLE 1.7976931348623157e+308 00068 #endif 00069 00070 #ifndef MAXFLOAT 00071 #define MAXFLOAT ((float)3.40282347e+38) 00072 #endif 00073 00074 #ifdef BETWEEN 00075 #undef BETWEEN 00076 #endif 00077 #define BETWEEN(a,b,c) (((a) <= (b)) && ((b) <= (c))) 00078 00079 #ifndef M_PI 00080 #define M_PI 3.14159265358979323846 00081 #endif 00082 00083 #ifndef SQRT2 00084 #define SQRT2 1.41421356237309504880 00085 #endif 00086 00087 #define ROUND(f) ((f>=0)?(int)(f + .5):(int)(f - .5)) 00088 #define RADIANS(deg) ((deg)/180.0 * M_PI) 00089 #define DEGREES(rad) ((rad)/M_PI * 180.0) 00090 00091 #define SQR(a) ((a) * (a)) 00092 00093 #ifdef HAVE_SINCOS 00094 extern void sincos(double x, double *s, double *c); 00095 #else 00096 # define sincos(x,s,c) *s = sin(x); *c = cos(x) 00097 #endif 00098 00099 #ifdef __cplusplus 00100 } 00101 #endif 00102 00103 #endif
1.7.4