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