Finding Intersection of NSMutableArrays

Use NSMutableSet: NSMutableSet *intersection = [NSMutableSet setWithArray:array1]; [intersection intersectSet:[NSSet setWithArray:array2]]; [intersection intersectSet:[NSSet setWithArray:array3]]; NSArray *array4 = [intersection allObjects]; The only issue with this is that you lose ordering of elements, but I think (in this case) that that’s OK. As has been pointed out in the comments (thanks, Q80!), iOS 5 and OS X 10.7 …

Read more

3D Line-Plane Intersection

Here is a Python example which finds the intersection of a line and a plane. Where the plane can be either a point and a normal, or a 4d vector (normal form), In the examples below (code for both is provided). Also note that this function calculates a value representing where the point is on …

Read more