Skip to content

Instantly share code, notes, and snippets.

@jkatayama
Created March 2, 2016 09:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkatayama/51d63cca1f6a2c04400e to your computer and use it in GitHub Desktop.
Save jkatayama/51d63cca1f6a2c04400e to your computer and use it in GitHub Desktop.
math.swift
### 二つの点の距離
``` 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