home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / server / ddx / mi / mifpoly.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-15  |  2.6 KB  |  73 lines

  1. /* $XConsortium: mifpoly.h,v 1.6 90/05/15 18:37:06 keith Exp $ */
  2. /***********************************************************
  3. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  4. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  5.  
  6.                         All Rights Reserved
  7.  
  8. Permission to use, copy, modify, and distribute this software and its 
  9. documentation for any purpose and without fee is hereby granted, 
  10. provided that the above copyright notice appear in all copies and that
  11. both that copyright notice and this permission notice appear in 
  12. supporting documentation, and that the names of Digital or MIT not be
  13. used in advertising or publicity pertaining to distribution of the
  14. software without specific, written prior permission.  
  15.  
  16. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  17. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  18. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  19. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  20. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  21. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  22. SOFTWARE.
  23.  
  24. ******************************************************************/
  25.  
  26. #define EPSILON    0.000001
  27. #define ISEQUAL(a,b) (fabs((a) - (b)) <= EPSILON)
  28. #define UNEQUAL(a,b) (fabs((a) - (b)) > EPSILON)
  29. #define WITHINHALF(a, b) (((a) - (b) > 0.0) ? (a) - (b) < 0.5 : \
  30.                          (b) - (a) <= 0.5)
  31. #define ROUNDTOINT(x)   ((int) (((x) > 0.0) ? ((x) + 0.5) : ((x) - 0.5)))
  32. #define ISZERO(x)     (fabs((x)) <= EPSILON)
  33. #define PTISEQUAL(a,b) (ISEQUAL(a.x,b.x) && ISEQUAL(a.y,b.y))
  34. #define PTUNEQUAL(a,b) (UNEQUAL(a.x,b.x) || UNEQUAL(a.y,b.y))
  35. #define PtEqual(a, b) (((a).x == (b).x) && ((a).y == (b).y))
  36.  
  37. #define NotEnd        0
  38. #define FirstEnd    1
  39. #define SecondEnd    2
  40.  
  41. #define SQSECANT 108.856472512142 /* 1/sin^2(11/2) - for 11o miter cutoff */
  42. #define D2SECANT 5.21671526231167 /* 1/2*sin(11/2) - max extension per width */
  43.  
  44. #ifdef NOINLINEICEIL
  45. #define ICEIL(x) ((int)ceil(x))
  46. #else
  47. #ifdef __GNUC__
  48. static __inline int ICEIL(x)
  49.     double x;
  50. {
  51.     int _cTmp = x;
  52.     return ((x == _cTmp) || (x < 0.0)) ? _cTmp : _cTmp+1;
  53. }
  54. #else
  55. #define ICEIL(x) ((((x) == (_cTmp = (x))) || ((x) < 0.0)) ? _cTmp : _cTmp+1)
  56. #define ICEILTEMPDECL static int _cTmp;
  57. #endif
  58. #endif
  59.  
  60. /* Point with sub-pixel positioning.  In this case we use doubles, but
  61.  * see mifpolycon.c for other suggestions 
  62.  */
  63. typedef struct _SppPoint {
  64.     double    x, y;
  65. } SppPointRec, *SppPointPtr;
  66.  
  67. typedef struct _SppArc {
  68.     double    x, y, width, height;
  69.     double    angle1, angle2;
  70. } SppArcRec, *SppArcPtr;
  71.  
  72. extern SppPointRec miExtendSegment();
  73.