# sideOf: logic

5 messages
Open this post in threaded view
|

## sideOf: logic

 Hi all we have the following method on point and I do not get why (0@0) sideOf: (100@100) >>> #centersideOf: 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 --------------------------------------------Stéphane Ducasse03 59 35 87 52Assistant: Aurore Dalle FAX 03 59 57 78 50TEL 03 59 35 86 16S. Ducasse - Inria40, avenue Halley, Parc Scientifique de la Haute Borne, Bât.A, Park PlazaVilleneuve d'Ascq 59650France
Open this post in threaded view
|

## Re: sideOf: logic

 I'm not sure, but I suspect this is a helpful method for things in analytic geometry. I.e., if you have a ray and a point, it would allow you to determine the direction to move for the shortest path (in polar coordinates, for example). -t -- Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html
Open this post in threaded view
|

## Re: sideOf: logic

 It just occurred to me: If you have a graphic element, such as a triangle or rectangle, etc., and you want to know if a point lies inside it or outside it, you would want a method such as this one.   But I think you would need to apply it relative to a vertex of the polygon in question, since it assumes a ray starting at (0@0) to a given point (i.e., an adjoining vertex). -- Sent from: http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html