Question regarding CGRectIntersectsRect and rotated rectangular image
Posted
by user309030
on Stack Overflow
See other posts from Stack Overflow
or by user309030
Published on 2010-04-09T06:28:31Z
Indexed on
2010/04/09
6:33 UTC
Read the original article
Hit count: 259
xcode
|objective-c
Hi guys,
I've got a long rectangular image which is rotated at different kind of angles. However the frame of the rectangular image does not rotate along with the image and instead, the rotation causes the frame to to become larger to fit the rotated image. So when I used CGRectIntersectsRect, the collision detection is totally off because the other image colliding with the rectangular image will collide before it even reaches the visible area of the rect image. In case you don't really know what I'm talking about, have a look at the ascii drawing:
normal rectangular image frame, O -> pixels, |, – -> frame
|----------|
|OOOOOOOOOO|
|----------|
after rotation
|----------|
|O |
| O |
| O |
| O |
| O |
| O |
| O |
| O |
| O |
|----------|
I've read through some of the collision articles but all of them are talking about collision with a normal straight rectangle and what I really want is collision with a slanted image, preferably pixel collision detection. TIA for any suggestions made.
© Stack Overflow or respective owner