Login  Register

Re: sideOf: logic

Posted by webwarrior on Sep 11, 2020; 8:42pm
URL: https://forum.world.st/sideOf-logic-tp5121532p5121674.html

Stéphane Ducasse wrote

> Hi all
>
> we have the following method on point and I do not get
>
> why
>
> (0@0) sideOf: (100@100)
>  >>> #center
>
>
>
> sideOf: otherPoint
> "Returns #left, #right or #center if the otherPoint lies to the left,
> right or on the line given by the vector from 0@0 to self"
>
>
> | side |
> side := (self crossProduct: otherPoint) sign.
> ^ { #right . #center . #left } at: side + 2

Segment from 0@0 (origin) to 0@0 (receiver) has 0 length, so its direction
is undefined. Therefore you cannot expect meaningful answer here.




--
Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html