Re: Geometry problem (slightly OT)
Re: Geometry problem (slightly OT)
- Subject: Re: Geometry problem (slightly OT)
- From: Frederick Cheung <email@hidden>
- Date: Tue, 21 Sep 2004 16:00:27 +0200
On 21 Sep 2004, at 15:46, Graham Cox wrote:
This has got to be straightforward enough, but it's late, I've had an
18 hour day, and I just can't get my head around it...
Given two rectangles lying at arbitrary angles but crossing over one
another, how do I calculate the four points of the rhomboid
intersection formed? Obviously as the angle becomes closer and closer
to 0, the intersection area extends rapidly to infinity... also the
90° case is trivial. It can be assumed that the intersection never
includes any corners or ends of the rectangles - in fact they are
thick lines that extend far beyond the area of intersection.
The knowns are:
* A single point representing the centre of the intersection - both
rects are centred widthwise at this point.
* The angle between the rects and their angles on the plane
* The widths of both rects, which can differ
I would consider the simple case where one of the 2 rectanges is such
that its sides are vertical and horizontal (easily achieved by a
rotation). If we center this rectangle at the origin then this rectange
has vertical edges at +/- a and horizontal edges at +/- b for example.
Then find the line equations of the sides of the other rectangle and
plugin x=+/-a or y=+/-b to find the intersection point . Then check
that this point is on the line segments and not just the line. (this
can of course generate up to 8 solutions)
A page with illustrations very much like what I'm trying to convey
here is http://www.cs.unc.edu/~hoff/projects/comp205/proj2/index2.html
I need to find the black area's four corners, as in the upper three
diagrams.
Incidentally is there anything for finding arbitrary intersections,
unions and diffs of paths in Cocoa?
Are those things always well defined (i'm thinking of paths that
intersect each other)? At the very least one can have different
interpretations of what one means by the "inside"
Fred
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden