-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathSIMD3.swift
More file actions
66 lines (59 loc) · 1.47 KB
/
SIMD3.swift
File metadata and controls
66 lines (59 loc) · 1.47 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//
// SIMD3.swift
// SIMDAdditions
//
// Created by C.W. Betts on 9/24/20.
// Copyright © 2020 C.W. Betts. All rights reserved.
//
import Foundation
import simd
public extension SIMD3 where Scalar: Numeric {
@inlinable func allZero() -> Bool {
return x == 0 && y == 0 && z == 0
}
@inlinable static func ==(left: SIMD3<Scalar>, right: SIMD3<Scalar>) -> simd_int3 {
return simd_int3(left.x == right.x ? -1: 0, left.y == right.y ? -1: 0, left.z == right.z ? -1: 0)
}
@inlinable static func !=(left: SIMD3<Scalar>, right: SIMD3<Scalar>) -> simd_int3 {
return simd_int3(left.x != right.x ? -1: 0, left.y != right.y ? -1: 0, left.z != right.z ? -1: 0)
}
}
public extension SIMD3 {
@inlinable var xy: SIMD2<Scalar> {
get {
return SIMD2<Scalar>(x, y)
}
set {
x = newValue.x
y = newValue.y
}
}
@inlinable var yz: SIMD2<Scalar> {
get {
return SIMD2<Scalar>(y, z)
}
set {
y = newValue.x
z = newValue.y
}
}
@inlinable var xz: SIMD2<Scalar> {
get {
return SIMD2<Scalar>(x, z)
}
set {
x = newValue.x
z = newValue.y
}
}
@inlinable var zyx: SIMD3<Scalar> {
get {
return SIMD3<Scalar>(z, y, x)
}
set {
x = newValue.z
y = newValue.y
z = newValue.x
}
}
}