2014-03-22 12:23 GMT+01:00 Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com>:
2014-03-22 12:20 GMT+01:00 Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com>:
From the st80 ages, rectangle have allways been oriented.
You have an origin and a corner inst var, not 2 corners or vertices. And you have creation messages Rectangle class>>origin:corner: The conventions are that of latin scribes, the orientation of rectangle should be (left->right , top->down)
There is an assumption that a rectangle with negative width (right->left) or height (bottom->top) should be treated as empty. And this was globally well maintained except a few breakages introduced in Squeak along the years (but I hope I corrected most of the slips since then).
Now Igor and Stephane had another view more geometric and un-oriented, and wanted to change conventions/handling of empty rectangles in Pharo. I don't know how far they went, or even if it is feasible at all... IMO, it's a recipe for maximizing breakage/gain ratio.
Finally, it seems that the conventions about emptyness were preserved in Pharo so far, as you can notice in Rectangle comment. Though, the Squeak changes ensuring this invariant still do not have been integrated: https://code.google.com/p/pharo/issues/detail?id=2601 https://pharo.fogbugz.com/f/cases/2649/don-t-let-an-empty-Rectangle-intersec... (A change of bug number is not the best thing here, it make things harder to follow... like my remarks in https://pharo.fogbugz.com/f/cases/7108/Rectangle-intersects-and-if-none) Note that VW has Rectangle class>>vertex:vertex:, and we probably should
add such message...
Something like:
Point>>vertex: aPoint ^aRectangle vertex: self vertex: aPoint
Rectangle class>>vertex: point1 vertex: point2 ^self origin: (point1 min: point2) corner: (point1 max: point2)
2014-03-21 15:15 GMT+01:00 Noury Bouraqadi <bouraqadi@gmail.com>:
Inverting the origin and the corner of a rectangle changes the result of
intersection. I guess it's a bug, though I imagine that changing the code of Rectangle is likely to have deep/undesired consequences..
(0@0 corner: 100@100) intersects: (-50@ -50 corner: 80@80) ==> true (100@100 corner: 0@0) intersects: (-50@ -50 corner: 80@80) ==> false !!!!
Noury