home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / smalltal / 2337 < prev    next >
Encoding:
Text File  |  1992-11-20  |  1.7 KB  |  39 lines

  1. Newsgroups: comp.lang.smalltalk
  2. Path: sparky!uunet!mcsun!Germany.EU.net!ira.uka.de!rz.uni-karlsruhe.de!wiormac5.wiwi.uni-karlsruhe.de!geidel
  3. From: Joachim Geidel <geidel@wior360.wiwi.uni-karlsruhe.de>
  4. Subject: OW\ST R4.1 Patch for Polyline>>outlineIntersects:
  5. Message-ID: <1992Nov20.193717.19428@rz.uni-karlsruhe.de>
  6. X-Xxmessage-Id: <A732FD16A4017B07@wiormac5.wiwi.uni-karlsruhe.de>
  7. X-Xxdate: Fri, 20 Nov 92 19: 37:42 GMT
  8. Sender: usenet@rz.uni-karlsruhe.de (USENET 'No news is bad news' News System)
  9. Organization: WIOR, Universitaet Karlsruhe (Germany)
  10. X-Useragent: Nuntius v1.1.1d11
  11. Date: Fri, 20 Nov 1992 19:37:17 GMT
  12. Lines: 25
  13.  
  14. "Polyline>>outlineIntersects: answers false whenever a Polyline has only
  15. two points which have the same horizontal or vertical coordinate. This
  16. results from the first test in the method which checks if the bounds of
  17. the Polyline intersect aRectangle. If the Polyline is a horizontal or
  18. vertical line, the bounds have height resp. width 0, and the test fails.
  19. This is often wrong, of course, as the Polyline can still intersect the
  20. outline
  21. of the rectangle. The following method avoids this behaviour by skipping
  22. the first test if the Polyline has only two points."
  23.  
  24. 'From Objectworks\Smalltalk(R), Release 4.1 of 15 April 1992 on 20
  25. November 1992 at 8:26:40 pm'!
  26.  
  27. !Polyline methodsFor: 'testing'!
  28.  
  29. outlineIntersects: aRectangle
  30.     "Answer true if the receiver intersects the supplied rectangle."
  31.  
  32.     "Eliminate the trivial failures"
  33.     "But avoid incorrect answer when the receiver is only a horizontal or
  34. vertical 
  35.     line segment."
  36.     vertices size > 2 ifTrue: [(super outlineIntersects: aRectangle)
  37.             ifFalse: [^false]].
  38.     ^self class vertices: vertices intersectsRectangle: aRectangle! !
  39.