I have two CGRects, one of which is rotated. I need someway of detecting when they collide. CGRectIntersectsRect does not work for this, since it assumes they are not rotated. Is there anyway to go about doing this?
Asked
Active
Viewed 60 times
0
-
Can't you create a new `CGRect` representing the rotated rectangle and test using that? – Carl Norum Sep 10 '13 at 20:14
-
If you're testing with `frame` and not `bounds`, then of course you'll get false positives. Bounds takes into account transformation, and can be converted to and from the coordinates of some common superview with the `convertRect:to/fromView:` method – CodaFi Sep 10 '13 at 20:41
-
@CarlNorum The problem is that CGRect does not store rotation it only contains a point and a size, so it would do no good to create a new rect. – xizor Sep 10 '13 at 20:45
-
1@MartinR, Thank you I will look at that and respond on if it works or not. – xizor Sep 10 '13 at 20:46
-
I think I get it - you mean arbitrary rotations, not just 90 degrees. I was misunderstanding. – Carl Norum Sep 10 '13 at 20:46
-
@CodaFi, Thanks. But the issue is the same as above. Converting to a different rect does not help solve the issue that CGRectIntersectsRect does not expect a rotated rect. – xizor Sep 10 '13 at 20:48