Difference of Rectangles
Bert Freudenberg
bert at freudenbergs.de
Sun May 6 20:27:43 UTC 2007
On May 6, 2007, at 16:12 , Jim Rosenberg wrote:
> Consider two rectangles, a and b. The only constraint I will put on
> them is that neither contains the other. I wish to create a
> PolygonMorph programmatically consisting of a merge: b with b
> removed but all of a retained in the case a and b overlap. I think
> I see my way to how to do this, but if anyone knows of any code I
> can look at where something like this is already implemented I'd be
> much obliged.
>
> My idea for how to go about this is to use "turtle logic" more or
> less as follows: Start with the first vertex of a merge: b which is
> not inside of b. Proceed clockwise along the bounds of a merge: b;
> if you hit b turn left, if you hit a turn right. But this may be
> doing things the hard way.
Sounds reasonable. There is a polygon clipper in Rome that you could
take a look at. The class is named RomePolygonClipper in package Rome-
Reference at
http://squeaksource.com/Rome.html
Might be simpler if you state the larger problem you need this for.
- Bert -
More information about the Squeak-dev
mailing list
|