MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: rectangle intersection

  • To: mathgroup at smc.vnet.net
  • Subject: [mg36128] Re: rectangle intersection
  • From: "Hans Michel" <hansjm at bellsouth.net>
  • Date: Thu, 22 Aug 2002 04:33:06 -0400 (EDT)
  • References: <ajvoe5$i9o$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Frank

I don't have  Mathematica code but the principle is as follows:

To clip one rectangle against another, first determine whether they overlap.
This condition is true if there is an overlap:

  rect1->y1 > rect2->y0 && rect1->y0 < rect2->y1 &&
  rect1->x1 > rect2->x0 && rect1->x0 < rect2->x1

Also go here to learn more

http://www.daimi.au.dk/~mbl/cgcourse/wiki/clipping_lines.html
or search The Cohen-Sutherland Line-Clipping Algorithm and other clipping
algorithms.

If you already know this stuff and just want code. You may just need to
apply these algorithm in Mathematica.

There is a Built in option for the Graphics3D function call
PolygonIntersections -> False

You can try building your Rectangles in a plane using

 Show[
        Graphics3D
            [
             First
                    [Show[
                    Graphics3D[{Cuboid[{0, 0, 0}, {5, 1, 0}],
                    Cuboid[{3, 0, 0}, {4, 2, 0}] }],
                    PolygonIntersections -> False
                            ]
                    ]
            ]
]

The returning result should be different primitives that do not intersect.
If the rectangles do instersect?

See Tom Wickham-Jones' Book Mathematica Graphics p.441 he speaks of Clip3D
In his ExtendedGraphics`Geometry3D` package.

Unfortunately, I don't have it.

Hans
"Frank Brand" <frank.brand at t-online.de> wrote in message
news:ajvoe5$i9o$1 at smc.vnet.net...
> Dear colleagues,
>
> any hints on how to implement a very fast routine in Mathematica for
> testing if two rectangles have an intersection area?
> Thanks in advance
> Frank Brand
>
>




  • Prev by Date: Re: function mySet[]
  • Next by Date: Re: rectangle intersection
  • Previous by thread: rectangle intersection
  • Next by thread: Re: rectangle intersection