home *** CD-ROM | disk | FTP | other *** search
/ Graphics 16,000 / graphics-16000.iso / msdos / utils / graphtal.lzh / Graphtal.Amiga / mathutilities.h < prev    next >
C/C++ Source or Header  |  1980-02-02  |  1KB  |  43 lines

  1. /*
  2.  * mathutilities.h - global math definitions.
  3.  *
  4.  * Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
  5.  *                     University of Berne, Switzerland
  6.  * All rights reserved.
  7.  *
  8.  * This software may be freely copied, modified, and redistributed
  9.  * provided that this copyright notice is preserved on all copies.
  10.  *
  11.  * You may not distribute this software, in whole or in part, as part of
  12.  * any commercial product without the express consent of the authors.
  13.  *
  14.  * There is no warranty or other guarantee of fitness of this software
  15.  * for any purpose.  It is provided solely "as is".
  16.  *
  17.  */
  18.  
  19. #ifndef MathUtilities_H
  20. # define MathUtilities_H
  21.  
  22. #include <math.h>
  23.  
  24. #ifdef NO_DRAND48
  25. #include <stdlib.h>
  26. inline void   srand48(long seed) { srand((int)seed); }
  27. inline double drand48()          { return (double)( ((double)rand()) / ((double)(RAND_MAX)) ); }
  28. #else
  29. extern "C" void srand48(long);
  30. extern "C" double drand48();
  31. #endif
  32.  
  33. typedef double real;
  34. //typedef float real;
  35.  
  36. const real EPSILON = 0.00001;
  37.  
  38. inline real dtor(real degree) { return degree*M_PI/180.0; }
  39. inline real rtod(real rad)    { return rad*180.0/M_PI; }
  40. inline int  equal(real a, real b) { return fabs(a-b) < EPSILON; }
  41.  
  42. #endif // MathUtilities_H
  43.