You can use the hypot()
or hypotf()
function to calculate the hypotenuse. Given two points p1
and p2
:
CGFloat distance = hypotf(p1.x - p2.x, p1.y - p2.y);
And that’s it.
More Related Contents:
- How can I upload a photo to a server with the iPhone?
- How to load a UIView using a nib file created with Interface Builder
- Has anyone implemented the PayPal API through a native iPhone app?
- How to create custom easing function with Core Animation?
- UILongPressGestureRecognizer gets called twice when pressing down
- How to compare two NSDates: Which is more recent?
- Property vs. instance variable
- How to disable highlighting of the app icon?
- How to make one color transparent on a UIImage?
- Lazy load images in UITableViewCell
- Any quick and dirty anti-aliasing techniques for a rotated UIImageView?
- Landscape Mode ONLY for iPhone or iPad
- How to calculate the width of a text string of a specific font and font-size?
- Draw part of a circle
- Determining if an iPhone is Jail broken Programmatically
- Fixed labels in the selection bar of a UIPickerView
- Changing the userAgent of NSURLConnection
- UITextField in UIAlertView on iPhone – how to make it responsive?
- Make scrollbar always visible on UIScrollView?
- Entering background on iOS4 to play audio
- Obtaining an NSDecimalNumber from a locale specific string?
- Changing font size of tabbaritem
- How to make a superview intercept button touch events?
- MKMapView Zoom and Region
- What’s the difference between using CGFloat and float?
- Using MD5 hash on a string in cocoa? [duplicate]
- How can I set a button background color on iPhone?
- What happens to an iPhone app when iPhone goes into stand-by mode?
- Programmatically opening the settings app (iPhone) [duplicate]
- Is it possible to NOT dismiss a UIAlertView