Created
July 29, 2020 10:28
-
-
Save trilliwon/501290c7e4b1445a29bb92de223d9a1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import CoreGraphics | |
extension CGPoint { | |
/// Calculates the distance between two points in 2D space. | |
/// + returns: The distance from this point to the given point. | |
func distance(to point: CGPoint) -> CGFloat { | |
return sqrt(pow(point.x - self.x, 2) + pow(point.y - self.y, 2)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment