Skip to content

Instantly share code, notes, and snippets.

View Natata's full-sized avatar
🙌

Jonathan Natata

🙌
View GitHub Profile
@Natata
Natata / CMDeviceMotion.swift
Last active August 17, 2017 06:23 — forked from travisnewby/CMDeviceMotion.swift
Determine the direction of "gaze" of the device in any orientation
extension CMDeviceMotion {
func gaze(atOrientation orientation: UIInterfaceOrientation) -> SCNVector4 {
let attitude = self.attitude.quaternion
let aq = GLKQuaternionMake(Float(attitude.x), Float(attitude.y), Float(attitude.z), Float(attitude.w))
let pi2 = Double.pi/2
let final: SCNVector4
switch UIApplication.shared.statusBarOrientation {