separating-axis-theorem

Objective-C check if subviews of rotated UIViews intersect?

你说的曾经没有我的故事 提交于 2019-11-28 06:35:28
I don't know where to start with this one. Obviously CGRectIntersectsRect will not work in this case, and you'll see why. I have a subclass of UIView that has a UIImageView inside it that is placed in the exact center of the UIView: I then rotate the custom UIView to maintain the frame of the inner UIImageView while still being able to perform a CGAffineRotation. The resulting frame looks something like this: I need to prevent users from making these UIImageViews intersect, but I have no idea how to check intersection between the two UIImageViews, since not only do their frames not apply to

Determine if crop rect is entirely contained within rotated UIView

白昼怎懂夜的黑 提交于 2019-11-27 16:56:34
问题 Premise: I'm building a cropping tool that handles two-finger arbitrary rotation of an image as well as arbitrary cropping. Sometimes the image ends up rotated in a way that empty space is inserted to fill a gap between the rotated image and the crop rect (see the examples below). I need to ensure that the image view, when rotated, fits entirely into the cropping rectangle. If it doesn't, I then need to re-transform the image (zoom it) so that it fits into the crop bounds. Using this answer,

Objective-C check if subviews of rotated UIViews intersect?

家住魔仙堡 提交于 2019-11-27 01:24:52
问题 I don't know where to start with this one. Obviously CGRectIntersectsRect will not work in this case, and you'll see why. I have a subclass of UIView that has a UIImageView inside it that is placed in the exact center of the UIView: I then rotate the custom UIView to maintain the frame of the inner UIImageView while still being able to perform a CGAffineRotation. The resulting frame looks something like this: I need to prevent users from making these UIImageViews intersect, but I have no idea

Algorithm to detect intersection of two rectangles?

半城伤御伤魂 提交于 2019-11-26 00:45:32
问题 I\'m looking for an algorithm to detect if two rectangles intersect (one at an arbitrary angle, the other with only vertical/horizontal lines). Testing if a corner of one is in the other ALMOST works. It fails if the rectangles form a cross-like shape. It seems like a good idea to avoid using slopes of the lines, which would require special cases for vertical lines. 回答1: The standard method would be to do the separating axis test (do a google search on that). In short: Two objects don't