Better collisions detection than CGRectIntersectsRect - ios

My character is represented by an UIImageView with that is 30 by 30 points. The enemy is another image view that is 240 points wide and 45 points tall. It appease that CGRectIntersectsRect only determines a collision between the two rectangular boxes. But I'm looking for something with more detail.
I'm not using SpriteKit or Cocos2d or Box2d or chipmunk. Is there anything better than CGRectIntersectsRect for corner collision detection and collision detection from the left and right sides and how do I program it?

Related

How to reduce the view of camera in ARKit?

I put 180 planes around camera in each 2 degree.The count of plane show in view is deal due to the degree of planes is deal.
How to change the view of camera in ARKit to make the count of plane less than normal?
You cannot change the view of the camera as it is tightly coupled to physical camera of your device. What you could do is create a shader which will add a section plane.
To reduce the RGB view produced by ARCamera use SKCropNode from SpriteKit framework:
class SKCropNode: SKNode
Apple documentation says about it the following:
SKCropNode masks pixels drawn by its children so that only some pixels are seen

Example from three.js but how to implement using SceneKit?

Example of goal:
I see three.js has this example.
It's simply a 3D Cube with many Spheres on its surface.
How can I do something like this using SceneKit?
You could use an array of points, on planes, and place spheres at those locations.
Each plane divide by 10 in both directions (X and Y) and then make six of these planes and rotate them into the cube face positions.
I think performance is probably going to suck, though. This is a lot of polygons, for each of these spheres. Let's imagine each sphere has 200 tris. That's 100x 6x 200 = 1.2 million triangles.
Probably better to use circular textures on quads, placed facing the camera, at each of these 600 points. Then it's only 1200 triangles.
Cheats way to do this:
Create a SCNBox with the number of vertices desired in x, y & z axis.
Then use it as a particle emitter shape, and assign emittance to each vertex at a rate that makes them always appear at these locations, using a small circle texture, and the "look at camera" mode of placard presentation.
here is that cheat, done with particles:

Motion blur robust edge detection

I need to detect squares on an image (for AR marker detection). Squares are rotated in 3D (meaning their projection I'm seeing isn't really a square but a 4 sided polygon). My problem is that the polygons I need to detect are moving so they are subject to motion blur. Squares are black with a white margin so there's a high contrast.
My approach for detection was to detect edges (canny for example), find contours, approximate polygons and filter them by the number of sides and maybe some other geometrical constraints.
What approach would you recommend for detecting edges on an image with a motion blur?
Thanks
I would use Harris corner detection to detect the corner points and then use Hough transform to detect the lines. Using the position of the corners and lines it is possible to get the polygons.

Detecting accurate collision of two views in ios programming?

I am making a "air hockey" type of game, I need to detect the collision of handle and puck in that. I am using the CGRectIntersectRect function for that but it is not accurate as when the frames from the edges collide, a collision is detected when the circles of puck and handle are not yet collided.
I hope I am making my point clear, so, any guidence on how I can achieve a more accurate collision of two circular images ?
I'd give a shot to UIKit Dynamics collision detection engine. See example here.
Unfortunately it's iOS 7+, so if you plan to support iOS 6, you need to look for another solution.
Taking the tip from #H2CO3, I implemented a function of my own that takes the center of circle 1 (x1,y1) and centre of circle 2 (x2,y2) and sum of radius of two circles (r) as parameters.
Calculates the distance between (x1,y1) and (x2,y2), if the distance, say d, is less than r then the circles are intersecting.
Have a look at the implementation, works perfectly:
-(BOOL)WhenCircleDistanceIsLessThanRadiusX1:(int)x1 Y1:(int)y1 X2:(int)x2 Y2:(int)y2 R:(int)r
{
int d = (int) sqrt(pow((x2-x1),2) + pow((y2-y1),2));
return(d<=r);
}

drawing overlapping circles in corona

How to draw a circle overlapping another circle in the moved phase of touch event,such that no gap is left out between the circles.The circles must be tightly packed to one another,so that even when user moves his hand on the screen faster or lightly,no gap must be present between the circles.
Just two circles? Or many circles? If just two, then detecting if they overlap is simply verifying that their centers are not closer than the sum of their radii. For example, if Circle1's raduis is 10 pixels, and Circle2's radius is 25 pixels, then they overlap if the center of Circle1 is less than 35 pixels from the center of Circle2.
So if you do your calculations in the "moved" phase and find that they're too close, you have to adjust the position of one of them. How you go about that will depend on the specifics of your application. You could:
Keep the y coordinate of the moving circle the same, and calculate the necessary x coordinate to maintain the required distance.
Same as above but swap x and y.
As above, but move the "unmoving" circle away from the "moving" circle.
Some other calculation that makes sense for your application.
NOTE: You should accept some of the answers you've been given.

Resources