-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathUtilities.swift
42 lines (34 loc) · 1002 Bytes
/
Utilities.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
See LICENSE folder for this sample’s licensing information.
Abstract:
Utility functions and type extensions used throughout the projects.
*/
import Foundation
import ARKit
import simd
// MARK: - float4x4 extensions
extension ARFrame.WorldMappingStatus: CustomStringConvertible {
public var description: String {
switch self {
case .notAvailable:
return "Not Available"
case .limited:
return "Limited"
case .extending:
return "Extending"
case .mapped:
return "Mapped"
}
}
}
// MARK: - CGPoint extensions
extension CGPoint {
/// Extracts the screen space point from a vector returned by SCNView.projectPoint(_:).
init(_ vector: SCNVector3) {
self.init(x: CGFloat(vector.x), y: CGFloat(vector.y))
}
/// Returns the length of a point when considered as a vector. (Used with gesture recognizers.)
var length: CGFloat {
return sqrt(x * x + y * y)
}
}