• 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: Maths Calculation Problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Maths Calculation Problem


  • Subject: Re: Maths Calculation Problem
  • From: Skeeve <email@hidden>
  • Date: Fri, 14 Nov 2008 19:30:51 +0100

Emmanuel Levy schrieb:
In fact it's easier to consider the reverse question: when do two rectangles R1 and R2 *not* intersect.

They don't intersect if any of these conditions is fulfilled:

- the left edge of R1 is to the right of the right edge of R2,
- the right edge of R1 is to the left of the left edge of R2,
- the top edge of R1 is lower than the bottom edge of R2,
- the bottom edge of R1 is upper than the top edge of R2.

If none of those are true, then R1 and R2 do intersect.

So this should do the correct maths:

set Object1 to {bounds:{523, 520, 750, 464}, width:227, height:56}
set Object2 to {bounds:{501, 569, 738, 514}, width:237, height:55}

return intersect(Object1, Object2)

to intersect(o1, o2)
   set {L1, T1, R1, B1} to bounds of o1
   set {L2, T2, R2, B2} to bounds of o2
   return not ((L1 > R2) or (L2 > R1) or (B1 > T2) or (B2 > T1))
end intersect

Question is: Do these objects intersect?
set Object1 to {bounds:{10, 20, 20, 10}, width:10, height:10}
set Object2 to {bounds:{20, 30, 30, 20}, width:10, height:10}
They share the corner (20,20).
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Follow-Ups:
    • Re: Maths Calculation Problem
      • From: Doug McNutt <email@hidden>
References: 
 >Maths Calculation Problem (From: Simon Topliss <email@hidden>)
 >Re: Maths Calculation Problem (From: Emmanuel Levy <email@hidden>)

  • Prev by Date: [Finder] Menu localization difference on Leopard vs Tiger
  • Next by Date: Re: [Finder] Menu localization difference on Leopard vs Tiger
  • Previous by thread: Re: Maths Calculation Problem
  • Next by thread: Re: Maths Calculation Problem
  • Index(es):
    • Date
    • Thread