Possible Duplicate:
Convert to absolute value in Objective-C
As i am playing with 2d graphics, i’d like to calculate amount of points object has moved between 2 CGPoints. Given that object can move in both direction, i am only interested in sheer number of points representing the difference.
In Java i’d Math.abs(startpoint.x - endpoint.x)
How can i do the same in Objective-C?
There are C functions from
<math.h>that will do what you want:Given that
CGPointstructures are composed ofCGFloats, you should usefabsfhere.Check out the Wikipedia page