Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
koher committed Jul 27, 2018
1 parent c5a5643 commit db9fdf8
Showing 1 changed file with 4 additions and 26 deletions.
30 changes: 4 additions & 26 deletions README.md
Expand Up @@ -14,53 +14,31 @@ let quotient = a / 2 // [1.0, 0.5]
let length = a.length // 2.23607
let distance = a.distance(from: b) // 6.08276

let dotProduct = a.dotProduct(with: b) // 0.0
let dotProduct = a.dot(b) // 0.0
let angle = a.angle(from: b) // 1.5708

let c: Vector3 = [1.0, 2.0, -2.0]
let unit = c.unit // [0.333333, 0.666667, -0.666667]

// interoperability with CoreGraphics
// Conversions between vector types and CoreGraphics types
let v = Vector2(CGPoint(x: 2.0, y: 3.0))
let p = CGPoint(v)
```

With SwiftyVector, `CGPoint` can be also used as a `Vector`.

```swift
import SwiftyVector
import CoreGraphics

// CGPoint as a Vector
let a: CGPoint = [2.0, 1.0]
let b: CGPoint = [-3.0, 6.0]

let sum = a + b // [-1.0, 7.0]
let difference = a - b // [5.0, -5.0]
let product = a * 2 // [4.0, 2.0]
let quotient = a / 2 // [1.0, 0.5]

let length = a.length // 2.23607
let distance = a.distance(from: b) // 6.08276

let dotProduct = a.dotProduct(with: b) // 0.0
let angle = a.angle(from: b) // 1.5708
```

## Installation

### Swift Package Manager

```swift
dependencies: [
.package(url: "https://github.com/koher/SwiftyVector.git", from: "0.3.0"),
.package(url: "https://github.com/koher/SwiftyVector.git", .branch("dev-0.4.0")),
]
```

### Carthage

```
github "koher/SwiftyVector" ~> 0.3.0
github "koher/SwiftyVector" "dev-0.4.0"
```

## License
Expand Down

0 comments on commit db9fdf8

Please sign in to comment.