• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Geometry problem (slightly OT)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Geometry problem (slightly OT)


  • Subject: Re: Geometry problem (slightly OT)
  • From: Nicko van Someren <email@hidden>
  • Date: Tue, 21 Sep 2004 15:26:25 +0100

On 21 Sep 2004, at 14: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

This is easy. Given the way you have described the rectangles they can each be considered to consist of two parallel sides which are important and two ends which are unimportant. If the first rectangle has important sides A and B and the second has important sides C and D then the vertices of your rhomboid are the intersection point AC, AD, BC and BD.


Incidentally is there anything for finding arbitrary intersections, unions and diffs of paths in Cocoa?

What the union or intersection of two paths means really depends on which winding rule you are using (especially when you're looking at figure-of-eight paths). If you're using non-zero winding rules then the union is easy because you simply compose a path made out of the two original paths and it just works. If you want the intersection under non-zero rules then essentially you're asking for the region where the winding count is less than -1 or more than 1 for the composition of the two paths.


I have some code which does this as part of solving another problem but it's fairly ugly. Finding the intersection of two Bezier curves is a pain since it involves finding up to nine roots of a nasty equation. The bezierPathByFlatteningPath message come to your rescue but means that you're not really solving the real problem. If you're interested I can send you some of the code, though it's nasty to look at and suffers in a few pathological cases.

	Nicko

_______________________________________________
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


  • Follow-Ups:
    • Re: Geometry problem (slightly OT)
      • From: Graham Cox <email@hidden>
References: 
 >Geometry problem (slightly OT) (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Geometry problem (slightly OT)
  • Next by Date: Re: Geometry problem (slightly OT)
  • Previous by thread: Re: Geometry problem (slightly OT)
  • Next by thread: Re: Geometry problem (slightly OT)
  • Index(es):
    • Date
    • Thread