Skip to content

Instantly share code, notes, and snippets.

View matthewreagan's full-sized avatar

Matt Reagan matthewreagan

View GitHub Profile
@matthewreagan
matthewreagan / Quaternion.swift
Created June 15, 2020 20:28
SceneKit Quaternion from Axis + Angle
import SceneKit
extension SCNVector3 {
func normalized() -> SCNVector3 {
let magnitude = ((self.x * self.x) + (self.y * self.y) + (self.z * self.z)).squareRoot()
return SCNVector3(self.x / magnitude, self.y / magnitude, self.z / magnitude)
}
}
func QuaternionFromAxisAngle(_ inAxis: SCNVector3, radians: CGFloat) -> SCNQuaternion {