[squeak-dev] Rectangle >> intersects: "degenerate case" -- *wrong* behavior??

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Tue Jan 15 00:49:26 UTC 2013


Well, the old behavior of intersects: was wrong with respect to intersect:

This is because intersect: answer an "empty" rectangle (negative width
or height).
Such intersection HAS TO BE EMPTY, and thus cannot intersects: anything...

To accomodate the degenerated case (one null dimension, the other
positive or null) we can change the final tests to strict
inequalities. OK?

Nicolas

2013/1/15 Jim Rosenberg <jr at amanue.com>:
> [Apologies in advance if this has been discussed up here before ...]
>
> Grumble grumble grumble grumble. Grrr!
>
> Consider the case of rectangle a and rectangle b where a happens to be
> "degenerate" in the sense that it has 0 area -- let's say that a origin y =
> a corner y -- i.e. if you draw a it looks like a horizontal line. And let's
> say that if you draw these two rectangles, a "goes inside the area of" b. Do
> they intersect? I'd sure say yes. Squeak 3.8 says yes. Squeak 4.3 says no.
> *BUT* a intersect: b in Squeak 4.3 *does return* the part of a that's inside
> b.
>
> Looking at the code for Rectangle >> intersect: in 4.3, it sure looks to me
> like this behavior was introduced rather explicitly and deliberately.
>
> But is it correct? I'd say no. I'd say no-brainer no. I guess maybe somebody
> is thinking that Rectangle >> intersects: should produce an answer that
> agrees with the question: does a possible intersection have area greater
> than 0? Well, sorry, but I don't think that's the right question. The right
> question is: do the two rectangles have points in common?
>
> I have code that was very mysteriously broken by this; I've created a
> degenerate rectangle out of a line *on purpose* just to be able to get the
> intersection of a line and a rectangle. I don't see any reason why I
> shouldn't be able to do this. Set theory says I can do it. Geometry says I
> can do it. Squeak 3.8 says I can do it.
>
> So: whichever committer out there decided that a degenerate rectangle can't
> intersect, what exactly will I break if I put back the [correct, ahem ...]
> 3.8 behavior of Rectangle >> intersect: in 4.3?
>
> I say: put the old behavior back. It wasn't wrong. The new behavior is
> wrong.
>
> -Thanks, Jim
>


More information about the Squeak-dev mailing list