using Objective-C for iPhone, I'm attempting to gather the closest object to my origin.
All my objects are in an NSMutableArray and have CGPoint property of their current location.
Using simple trig I can find the magnitudes of all my objects with ease, but Im trying to find the 'closest' object to my origin. Does anyone have any idea how to do this?
loop through all the objects, calculate the distance to your origin while keeping the minimum value?
distanceAO = sqrt(sqr(Ax-Ox)+sqr(Ay-Oy))