home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 3 / RISC_DISC_3.iso / resources / etexts / gems / gemsv / ch5_4 / poly.h < prev    next >
C/C++ Source or Header  |  1995-03-04  |  744b  |  34 lines

  1. /*************************************************
  2.  *  POLY.H
  3.  *  Andreas Leipelt, "Ray Tracing a Swept Sphere"
  4.  *  from "Graphics Gems", Academic Press
  5.  *
  6.  */
  7.  
  8. #ifndef POLY_CLASS
  9. #define POLY_CLASS
  10.  
  11. #define MAX_DEGREE 10
  12. #define polyeps 1E-10  // tolerance for polynomial coefficients
  13.  
  14. class polynomial {
  15.   public:
  16.  
  17.   int deg;
  18.   double coef[MAX_DEGREE+1];
  19.  
  20.   polynomial();
  21.   double     eval(double);
  22.   int        roots_between(double,double,double*);
  23.   double     min(double,double);
  24.   double     max(double,double);
  25.   polynomial derivative();
  26. };
  27.  
  28. polynomial operator+(polynomial&, polynomial&);
  29. polynomial operator-(polynomial&, polynomial&);
  30. polynomial operator*(polynomial&, polynomial&);
  31. polynomial operator*(double, polynomial&);
  32.  
  33. #endif
  34.