Hamilton

Swift Version License Platform

要求

使用 Swift 4。请注意。

基本用法

基本操作

let baseVector = Vector3(1, 6, 5)
let otherVector = Vector3(7, 1, 3)

baseVector.adding(otherVector) //=> Vector3(8, 7, 8)
baseVector.magnitude //=> 7.874

旋转

let baseVector = Vector3(0, 1, 0)

let quat = Quaternion(axis: .xAxis, angle: Degrees(90))
let eulerAngles = EulerAngles(pitch: 90.degrees, yaw: 0.degrees, roll: 0.degrees, system: .xyz)

baseVector.rotated(by: quat) //=> Vector3(0, 0, 1)
baseVector.rotated(by: eulerAngles) // -> Vector3(0, 0, 1)

安装

Hamilton 可通过 CocoaPods 获取。要安装它,只需将以下行添加到你的 Podfile

pod "Hamilton"

作者

Patrick Metcalfe, git@patrickmetcalfe.com

许可

Hamilton 在 MIT 许可下可用。有关更多信息,请参阅 LICENSE 文件。