Contents

koher/cgpointvector

_CGPointVector_ provides the extension for arithmetic operations with _CGPoint_ in __Swift__, which are convenient when _CGPoint_ values are used as vectors.

Usage

import CGPointVector

let a = CGPoint(x: 3.0, y: -4.0)
let b = CGPoint(x: 2.0, y: -5.0)

let sum = a + b // (5.0, -9.0)
let length = a.length // 5.0
let distance = a.distance(from: b) // 1.4142135623731
let unitVector = a.unit // (0.6, -0.8)
let dotProduct = a.dot(b) // 26.0
let angle = a.angle(from: b) // 0.26299473168091936

License

The MIT License

Package Metadata

Repository: koher/cgpointvector

Default branch: main

README: README.md