Determining If Rectangles Intersect?

March 5th, 2009 by jason Leave a reply »

Its funny the things one finds out are missing in a new framework.  Silverlight 2 is missing (as far as I can tell) a rectangle intersection/collision/overlapping test function.  I started writing my own and immediatly had a very nasty chunk of code.  I knew I was doing something wrong.  I found this short article which immediatly made me think back to college CompSci with its simple solution.  I need to test if two rectangles are overlapping, but the logic is easier if I write to test if they aren’t overlapping and negate the answer.  I have written an extension method in C# for the Silverlight Rect class to impliment logic similar to this.  Nifty!

Advertisement

Leave a Reply

You must be logged in to post a comment.