Created
March 2, 2016 09:16
-
-
Save jkatayama/51d63cca1f6a2c04400e to your computer and use it in GitHub Desktop.
math.swift
This file contains 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
### 二つの点の距離 | |
``` swift | |
func distance(pointA: CGPoint, pontB: CGPoint) -> Float { | |
let dx: Float = abs(pointA.x - pontB.x) | |
let dy: Float = abs(pointA.y - pontB.y) | |
let dist = sqrt(dx*dx + dy*dy) | |
return dist | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment