Get distance between two rectangles?

How do I calculate the closest distance between the outlines of two rectangle shapes?
I’m semi-randomly generating levels and want to ensure that certain objects (which are statically positioned rectangles with random coordinates and rotations) won’t be too close to each other.

Thanks for any help! [import]uid: 10284 topic_id: 6466 reply_id: 306466[/import]

Use contentBounds to find the outer edges of the rectangles:

http://developer.anscamobile.com/reference/index/objectcontentbounds [import]uid: 12108 topic_id: 6466 reply_id: 22364[/import]

Wouldn’t that return the overall bounding rectangle rather than a point on a plane?

Imagine a diamond shape… the bounding rectangle would then be a square. If you wanted to find the point midway along one edge of the diamond then this would give a different value to the edge of the bounding rectangle.

Hope that makes sense!
[import]uid: 8353 topic_id: 6466 reply_id: 22555[/import]

Thanks JHocking but yes, I believe the content bounds won’t work in this case, as my rectangles are rotated and I require the closest distance between any point of their outlines… [import]uid: 10284 topic_id: 6466 reply_id: 22565[/import]