arith.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /// @file
  2. /// @ingroup public_apis
  3. /*************************************************************************
  4. * Copyright (c) 2011 AT&T Intellectual Property
  5. * All rights reserved. This program and the accompanying materials
  6. * are made available under the terms of the Eclipse Public License v1.0
  7. * which accompanies this distribution, and is available at
  8. * https://www.eclipse.org/legal/epl-v10.html
  9. *
  10. * Contributors: Details at https://graphviz.org
  11. *************************************************************************/
  12. /* geometric functions (e.g. on points and boxes) with application to, but
  13. * no specific dependence on graphs */
  14. #pragma once
  15. #include <limits.h>
  16. #include <math.h>
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #ifdef MIN
  21. #undef MIN
  22. #endif
  23. #define MIN(a,b) ((a)<(b)?(a):(b))
  24. #ifdef MAX
  25. #undef MAX
  26. #endif
  27. #define MAX(a,b) ((a)>(b)?(a):(b))
  28. #ifdef BETWEEN
  29. #undef BETWEEN
  30. #endif
  31. #define BETWEEN(a,b,c) (((a) <= (b)) && ((b) <= (c)))
  32. #ifndef M_PI
  33. #define M_PI 3.14159265358979323846
  34. #endif
  35. #ifndef SQRT2
  36. #define SQRT2 1.41421356237309504880
  37. #endif
  38. #define ROUND(f) ((f>=0)?(int)(f + .5):(int)(f - .5))
  39. #define RADIANS(deg) ((deg)/180.0 * M_PI)
  40. #define DEGREES(rad) ((rad)/M_PI * 180.0)
  41. #define SQR(a) ((a) * (a))
  42. #ifdef __cplusplus
  43. }
  44. #endif