home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / opendc12.zip / od124os2.exe / od12osp1.exe / src / utils / LineOps.h < prev    next >
C/C++ Source or Header  |  1997-04-02  |  4KB  |  114 lines

  1. //====START_GENERATED_PROLOG======================================
  2. //
  3. //
  4. //   COMPONENT_NAME: odutils
  5. //
  6. //   CLASSES: none
  7. //
  8. //   ORIGINS: 82,27
  9. //
  10. //
  11. //   (C) COPYRIGHT International Business Machines Corp. 1995,1996
  12. //   All Rights Reserved
  13. //   Licensed Materials - Property of IBM
  14. //   US Government Users Restricted Rights - Use, duplication or
  15. //   disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  16. //       
  17. //   IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  18. //   ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  19. //   PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  20. //   CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  21. //   USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  22. //   OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
  23. //   OR PERFORMANCE OF THIS SOFTWARE.
  24. //
  25. //====END_GENERATED_PROLOG========================================
  26. //
  27. // @(#) 1.11 com/src/utils/include/LineOps.h, odutils, od96os2, odos29712d 3/14/97 16:49:53 [ 3/21/97 17:21:31 ]
  28. /*
  29.     File:        LineOps.h
  30.  
  31.     Contains:    Geometric operations on lines in 2-space.
  32.  
  33.     Owned by:    Jens Alfke
  34.                 IntersectLines by Ken Turkowski, from Apple Technical Memorandum KT14.
  35.  
  36.     Copyright:    (C) 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  37.  
  38.     Theory of Operation:
  39.     
  40.     Endpoints of lines or ranges need not be given in any particular order.
  41.     
  42.     Ranges include both endpoints, unline rectangles which don't include right and bottom.
  43.     (This is necessary to make segments that share an endpoint intersect, and to make e.g.
  44.     the horizontal range of a vertical line be non-empty.)
  45.     
  46. */
  47.  
  48.  
  49. #ifndef _LINEOPS_
  50. #define _LINEOPS_
  51.  
  52. #ifndef _ODTYPES_
  53. #include "ODTypes.h"
  54. #endif
  55.  
  56. #ifndef _ODMVCLNK_
  57. #include <ODMvcLnk.h>
  58. #endif
  59.  
  60.  
  61. enum{
  62.     kIntersection,                // Segments intersect
  63.     kOutsideIntersection,        // Lines intersect, but past ends of segments
  64.     kNoIntersection                // Lines are parallel or degenerate
  65. };
  66. typedef short IntersectionStatus;
  67.  
  68.  
  69. const ODCoordinate kFixedEpsilon = 7;        // This is about 0.0001 pixels
  70.  
  71.  
  72. extern "C" {
  73.  
  74.  
  75. inline ODCoordinate Min( ODCoordinate a, ODCoordinate b )    {return a<b ?a :b;}
  76. inline ODCoordinate Max( ODCoordinate a, ODCoordinate b )    {return a>b ?a :b;}
  77.  
  78. inline ODCoordinate Abs( ODCoordinate n )                    {return n>=0 ?n :-n;}
  79.  
  80. _DLLIMPORTEXPORT_ ODBoolean WithinEpsilon( ODCoordinate a, ODCoordinate b );
  81.  
  82. _DLLIMPORTEXPORT_ ODCoordinate    Distance( const ODPoint &p0, const ODPoint &p1 );
  83.  
  84. _DLLIMPORTEXPORT_ void        GetLineShift( ODPoint p0, ODPoint p1, ODCoordinate dist,
  85.                                     ODPoint &delta );
  86.  
  87. _DLLIMPORTEXPORT_ IntersectionStatus    IntersectLines( const ODPoint &p0, const ODPoint &p1,
  88.                                     const ODPoint &q0, const ODPoint &q1,
  89.                                     ODPoint *sect );
  90.                 
  91. _DLLIMPORTEXPORT_ ODBoolean    IntersectSegments( const ODPoint &p0, const ODPoint &p1,
  92.                                        const ODPoint &q0, const ODPoint &q1,
  93.                                        ODPoint *sect );
  94.  
  95. _DLLIMPORTEXPORT_ ODCoordinate    GetLineXAtY( const ODPoint &p0, const ODPoint &p1,
  96.                                        ODCoordinate y );
  97.  
  98. #ifdef _PLATFORM_MACINTOSH_
  99. Fract                GetIntersectionT( const ODPoint &p0, const ODPoint &p1,
  100. #else
  101. _DLLIMPORTEXPORT_ ODFract    GetIntersectionT( const ODPoint &p0, const ODPoint &p1,
  102. #endif
  103.                                       const ODPoint § );
  104.  
  105. _DLLIMPORTEXPORT_ ODBoolean    InRange( ODCoordinate n,  ODCoordinate r0, ODCoordinate r1 );
  106.  
  107. _DLLIMPORTEXPORT_ ODBoolean    RangesDisjoint( ODCoordinate a0, ODCoordinate a1,
  108.                                     ODCoordinate b0, ODCoordinate b1 );
  109.  
  110. }
  111.  
  112.  
  113. #endif /*_LINEOPS_*/
  114.