iOS How do I figure out the location of a CGPoint relative to another CGPoint?


ArtOfWarfare

macrumors G3
Nov 26, 2007
8,565
3,978
I can do this using math, but I don't want to if I don't have to.
Write a function that hides the math and use that function. What difference does it make if you or Apple writes the function - it'll be implemented the same way either way.
 

moonman239

macrumors 68000
Original poster
Mar 27, 2009
1,521
22
I just want to do things the Apple way.

The less code I have to write, the better, and the more likely I get to blame someone else for not letting a portion of my app work.
 

mobilehaathi

macrumors G3
Aug 19, 2008
9,347
6,218
The Anthropocene
I just want to do things the Apple way.

The less code I have to write, the better, and the more likely I get to blame someone else for not letting a portion of my app work.
Ok, to be fair I understand you not wanting to 'reinvent the wheel,' but honestly it should take you 30s to bang out this function.
 

ArtOfWarfare

macrumors G3
Nov 26, 2007
8,565
3,978
If you're getting into games and not using Sprite Kit, I suggest using someone else's game libraries. Most of them will provide distance between points equations.

Also note that if you're looking to determine if a point is within a certain distance of another point, there's no need to use a sqrt function which will take a relatively long time to run.