Skip to content

Commit 184bd1a

Browse files
committed
Add convenience properties
1 parent 1b68274 commit 184bd1a

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

Sources/GameMath/2D Types/2D Physics/Line2D.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ public struct Line2D: Sendable {
1616
}
1717

1818
public extension Line2D {
19+
@inlinable
20+
var direction: Direction2 {
21+
return Direction2(from: p1, to: p2)
22+
}
23+
1924
func pointNear(_ p: Position2) -> Position2 {
2025
let ab = p2 - p1
2126
let ap = p - p1

Sources/GameMath/3D Types/3D Physics/Line3D.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public struct Line3D: Sendable {
1818
}
1919

2020
public extension Line3D {
21+
@inlinable
22+
var direction: Direction3 {
23+
return Direction3(from: p1, to: p2)
24+
}
25+
2126
@inlinable
2227
func pointNear(_ p: Position3) -> Position3 {
2328
let ab = p2 - p1

Sources/GameMath/3D Types/Size3.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ public extension Size3 {
9494
self.y = newValue.y
9595
}
9696
}
97+
98+
99+
@inlinable
100+
var xz: Size2 {
101+
get {
102+
return Size2(x, z)
103+
}
104+
set {
105+
self.x = newValue.x
106+
self.z = newValue.y
107+
}
108+
}
97109
}
98110

99111
public extension Size3 {

0 commit comments

Comments
 (0)