From ba82762f457b08a623f73ccc2952f0458854bffc Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:29:13 +0200 Subject: [PATCH 01/21] Disable redundant_type_annotation rule in SwiftLint configuration --- .swiftlint.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index fd10715..bf40b6c 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -25,7 +25,6 @@ opt_in_rules: #- required_deinit #- type_contents_order #- unowned_variable_capture - - anyobject_protocol - array_init - attributes - closure_body_length @@ -48,7 +47,6 @@ opt_in_rules: - enum_case_associated_values_count - expiring_todo - explicit_init - - explicit_self - explicit_top_level_acl - fallthrough - fatal_error_message @@ -95,7 +93,6 @@ opt_in_rules: - raw_value_for_camel_cased_codable_enum - reduce_into - redundant_nil_coalescing - - redundant_type_annotation - required_enum_case - single_test_class - sorted_first_last @@ -109,11 +106,14 @@ opt_in_rules: - unavailable_function - unneeded_parentheses_in_closure_argument - untyped_error_in_catch - - unused_declaration - - unused_import - vertical_parameter_alignment_on_call - vertical_whitespace_between_cases - vertical_whitespace_closing_braces - vertical_whitespace_opening_braces - xct_specific_matcher - yoda_condition + +analyzer_rules: + - explicit_self + - unused_declaration + - unused_import From 88cb41e65a87588a9684499403a1a36e8b637f17 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:30:31 +0200 Subject: [PATCH 02/21] docs: add SwiftLint issues worklist --- SWIFTLINT_ISSUES.md | 58 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 SWIFTLINT_ISSUES.md diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md new file mode 100644 index 0000000..9ea6d64 --- /dev/null +++ b/SWIFTLINT_ISSUES.md @@ -0,0 +1,58 @@ +# SwiftLint Issues Worklist + +Total Violations: **113** across 101 files. + +--- + +## Task Checklist by Violation Category + +### 1. Static Operators (`static_operator`) - 43 violations +- [ ] `Sources/FirebladeMath/Matrix/Matrix+Operators.swift` (30 violations) +- [ ] `Sources/FirebladeMath/Quat/Quaternion+Operators.swift` (13 violations) + +### 2. Identifier Names (`identifier_name`) - 21 violations +- [ ] `Sources/FirebladeMath/Quat/Quat4f+Euler.swift` (12 violations: `e`, `q`) +- [ ] `Sources/FirebladeMath/Functions/determinant.swift` (6 violations: `a`, `b`, `c`) +- [ ] `Sources/FirebladeMath/Functions/adjugate.swift` (2 violations: `m`) + +### 3. Attribute Formatting (`attributes`) - 19 violations +- [ ] `Sources/FirebladeMath/Quat/Quat4f+Euler.swift` (4 violations) +- [ ] `Sources/FirebladeMath/Matrix/Matrix2x2.swift` (4 violations) +- [ ] `Sources/FirebladeMath/Matrix/Matrix3x3.swift` (4 violations) +- [ ] `Sources/FirebladeMath/Matrix/Matrix4x4.swift` (4 violations) +- [ ] `Sources/FirebladeMath/Quat/Quat4d.swift` (1 violation) +- [ ] `Sources/FirebladeMath/Matrix/Mat4x4d.swift` (1 violation) +- [ ] `Sources/FirebladeMath/Matrix/Mat4x4f.swift` (1 violation) + +### 4. Opening Brace Spacing (`opening_brace`) - 6 violations +- [ ] `Sources/FirebladeMath/Matrix/MatrixStorage+SIMD.swift` (6 violations) + +### 5. Multiline Arguments (`multiline_arguments`) - 6 violations +- [ ] `Sources/FirebladeMath/Functions/matrix.swift` (6 violations) + +### 6. Computed Accessors Order (`computed_accessors_order`) - 4 violations +- [ ] `Sources/FirebladeMath/Quat/QuaternionStorage+NO_SIMD.swift` (4 violations) + +### 7. Function Parameter Count (`function_parameter_count`) - 4 violations +- [ ] `Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift` (4 violations) + +### 8. Blanket Disable Commands (`blanket_disable_command`) - 3 violations +- [ ] `Sources/FirebladeMath/Matrix/MatrixStorage.swift` (1 violation) +- [ ] `Sources/FirebladeMath/Matrix/Matrix4x4.swift` (1 violation) +- [ ] `Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift` (1 violation) + +### 9. Identical Operands (`identical_operands`) - 2 violations +- [ ] `Sources/FirebladeMath/Functions/sign.swift` (2 violations) + +### 10. Large Tuples (`large_tuple`) - 2 violations +- [ ] `Sources/FirebladeMath/Matrix/Matrix3x3.swift` (1 violation) +- [ ] `Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift` (1 violation) + +### 11. Variable Whitespace (`let_var_whitespace`) - 1 violation +- [ ] `Sources/FirebladeMath/Quat/Quat.swift` (1 violation) + +### 12. File Length (`file_length`) - 1 violation +- [ ] `Sources/FirebladeMath/Matrix/Matrix+Multiplication.swift` (1 violation) + +### 13. TODO Comment (`todo`) - 1 violation +- [ ] `Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift` (1 violation) From ba41d5b79dfe909acab2b57c7ec5958d22aedb06 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:33:20 +0200 Subject: [PATCH 03/21] style: fix let_var_whitespace warning in Quat.swift --- SWIFTLINT_ISSUES.md | 2 +- Sources/FirebladeMath/Quat/Quat.swift | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md index 9ea6d64..7b9031e 100644 --- a/SWIFTLINT_ISSUES.md +++ b/SWIFTLINT_ISSUES.md @@ -49,7 +49,7 @@ Total Violations: **113** across 101 files. - [ ] `Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift` (1 violation) ### 11. Variable Whitespace (`let_var_whitespace`) - 1 violation -- [ ] `Sources/FirebladeMath/Quat/Quat.swift` (1 violation) +- [x] `Sources/FirebladeMath/Quat/Quat.swift` (1 violation) ### 12. File Length (`file_length`) - 1 violation - [ ] `Sources/FirebladeMath/Matrix/Matrix+Multiplication.swift` (1 violation) diff --git a/Sources/FirebladeMath/Quat/Quat.swift b/Sources/FirebladeMath/Quat/Quat.swift index c297140..69bf7dc 100644 --- a/Sources/FirebladeMath/Quat/Quat.swift +++ b/Sources/FirebladeMath/Quat/Quat.swift @@ -5,6 +5,7 @@ public struct Quaternion: Sendable { /// The scalar type used in the quaternion. public typealias Value = Storage.Value + @usableFromInline var storage: Storage /// Creates a quaternion from a storage object. From f42defcf7fd88e27b6ce868fee51b65c8860c437 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:34:18 +0200 Subject: [PATCH 04/21] style: fix opening_brace warnings in MatrixStorage+SIMD.swift --- SWIFTLINT_ISSUES.md | 2 +- .../Matrix/MatrixStorage+SIMD.swift | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md index 7b9031e..0bde69c 100644 --- a/SWIFTLINT_ISSUES.md +++ b/SWIFTLINT_ISSUES.md @@ -25,7 +25,7 @@ Total Violations: **113** across 101 files. - [ ] `Sources/FirebladeMath/Matrix/Mat4x4f.swift` (1 violation) ### 4. Opening Brace Spacing (`opening_brace`) - 6 violations -- [ ] `Sources/FirebladeMath/Matrix/MatrixStorage+SIMD.swift` (6 violations) +- [x] `Sources/FirebladeMath/Matrix/MatrixStorage+SIMD.swift` (6 violations) ### 5. Multiline Arguments (`multiline_arguments`) - 6 violations - [ ] `Sources/FirebladeMath/Functions/matrix.swift` (6 violations) diff --git a/Sources/FirebladeMath/Matrix/MatrixStorage+SIMD.swift b/Sources/FirebladeMath/Matrix/MatrixStorage+SIMD.swift index c470fad..8cb7a08 100644 --- a/Sources/FirebladeMath/Matrix/MatrixStorage+SIMD.swift +++ b/Sources/FirebladeMath/Matrix/MatrixStorage+SIMD.swift @@ -11,8 +11,7 @@ import struct simd.matrix.simd_float4x4 /// Conformance to matrix storage protocols. extension simd_float2x2: Storage2x2Protocol, @retroactive @unchecked Sendable, @retroactive RandomAccessCollection, @retroactive MutableCollection, @retroactive RangeReplaceableCollection, @retroactive BidirectionalCollection, @retroactive Collection, - @retroactive Sequence -{ + @retroactive Sequence { /// The element type of the matrix storage. public typealias Element = Float /// The column vector type of the matrix. @@ -59,8 +58,7 @@ extension simd_float2x2: Storage2x2Protocol, @retroactive @unchecked Sendable, @ /// Conformance to matrix storage protocols. extension simd_double2x2: Storage2x2Protocol, @retroactive @unchecked Sendable, @retroactive RandomAccessCollection, @retroactive MutableCollection, @retroactive RangeReplaceableCollection, @retroactive BidirectionalCollection, @retroactive Collection, - @retroactive Sequence -{ + @retroactive Sequence { /// The element type of the matrix storage. public typealias Element = Double /// The column vector type of the matrix. @@ -109,8 +107,7 @@ extension simd_double2x2: Storage2x2Protocol, @retroactive @unchecked Sendable, /// Conformance to matrix storage protocols. extension simd_float3x3: Storage3x3Protocol, @retroactive @unchecked Sendable, @retroactive RandomAccessCollection, @retroactive MutableCollection, @retroactive RangeReplaceableCollection, @retroactive BidirectionalCollection, @retroactive Collection, - @retroactive Sequence -{ + @retroactive Sequence { /// The element type of the matrix storage. public typealias Element = Float /// The column vector type of the matrix. @@ -163,8 +160,7 @@ extension simd_float3x3: Storage3x3Protocol, @retroactive @unchecked Sendable, @ /// Conformance to matrix storage protocols. extension simd_double3x3: Storage3x3Protocol, @retroactive @unchecked Sendable, @retroactive RandomAccessCollection, @retroactive MutableCollection, @retroactive RangeReplaceableCollection, @retroactive BidirectionalCollection, @retroactive Collection, - @retroactive Sequence -{ + @retroactive Sequence { /// The element type of the matrix storage. public typealias Element = Double /// The column vector type of the matrix. @@ -219,8 +215,7 @@ extension simd_double3x3: Storage3x3Protocol, @retroactive @unchecked Sendable, /// Conformance to matrix storage protocols. extension simd_float4x4: Storage4x4Protocol, @retroactive @unchecked Sendable, @retroactive RandomAccessCollection, @retroactive MutableCollection, @retroactive RangeReplaceableCollection, @retroactive BidirectionalCollection, @retroactive Collection, - @retroactive Sequence -{ + @retroactive Sequence { /// The element type of the matrix storage. public typealias Element = Float /// The column vector type of the matrix. @@ -279,8 +274,7 @@ extension simd_float4x4: Storage4x4Protocol, @retroactive @unchecked Sendable, @ /// Conformance to matrix storage protocols. extension simd_double4x4: Storage4x4Protocol, @retroactive @unchecked Sendable, @retroactive RandomAccessCollection, @retroactive MutableCollection, @retroactive RangeReplaceableCollection, @retroactive BidirectionalCollection, @retroactive Collection, - @retroactive Sequence -{ + @retroactive Sequence { /// The element type of the matrix storage. public typealias Element = Double /// The column vector type of the matrix. From 4873c7fdb52b0e43e8c1e5a9a73982bc429a09c3 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:34:56 +0200 Subject: [PATCH 05/21] style: fix computed_accessors_order warnings in QuaternionStorage+NO_SIMD.swift --- SWIFTLINT_ISSUES.md | 2 +- .../FirebladeMath/Quat/QuaternionStorage+NO_SIMD.swift | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md index 0bde69c..2dbfbf5 100644 --- a/SWIFTLINT_ISSUES.md +++ b/SWIFTLINT_ISSUES.md @@ -31,7 +31,7 @@ Total Violations: **113** across 101 files. - [ ] `Sources/FirebladeMath/Functions/matrix.swift` (6 violations) ### 6. Computed Accessors Order (`computed_accessors_order`) - 4 violations -- [ ] `Sources/FirebladeMath/Quat/QuaternionStorage+NO_SIMD.swift` (4 violations) +- [x] `Sources/FirebladeMath/Quat/QuaternionStorage+NO_SIMD.swift` (4 violations) ### 7. Function Parameter Count (`function_parameter_count`) - 4 violations - [ ] `Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift` (4 violations) diff --git a/Sources/FirebladeMath/Quat/QuaternionStorage+NO_SIMD.swift b/Sources/FirebladeMath/Quat/QuaternionStorage+NO_SIMD.swift index 74559e6..0107a4d 100644 --- a/Sources/FirebladeMath/Quat/QuaternionStorage+NO_SIMD.swift +++ b/Sources/FirebladeMath/Quat/QuaternionStorage+NO_SIMD.swift @@ -14,23 +14,23 @@ public struct QuaternionStorage: QuaternionStorageProtocol } @inlinable public var x: Value { - set { storage.x = newValue } get { storage.x } + set { storage.x = newValue } } @inlinable public var y: Value { - set { storage.y = newValue } get { storage.y } + set { storage.y = newValue } } @inlinable public var z: Value { - set { storage.z = newValue } get { storage.z } + set { storage.z = newValue } } @inlinable public var w: Value { - set { storage.w = newValue } get { storage.w } + set { storage.w = newValue } } public func makeIterator() -> SIMDScalarIterator> { From 763a03d45694d5f10fccb0340f58eb2b2e95c729 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:35:46 +0200 Subject: [PATCH 06/21] style: fix multiline_arguments warnings in matrix.swift --- SWIFTLINT_ISSUES.md | 2 +- Sources/FirebladeMath/Functions/matrix.swift | 54 +++++++++++++------- 2 files changed, 37 insertions(+), 19 deletions(-) diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md index 2dbfbf5..32f667f 100644 --- a/SWIFTLINT_ISSUES.md +++ b/SWIFTLINT_ISSUES.md @@ -28,7 +28,7 @@ Total Violations: **113** across 101 files. - [x] `Sources/FirebladeMath/Matrix/MatrixStorage+SIMD.swift` (6 violations) ### 5. Multiline Arguments (`multiline_arguments`) - 6 violations -- [ ] `Sources/FirebladeMath/Functions/matrix.swift` (6 violations) +- [x] `Sources/FirebladeMath/Functions/matrix.swift` (6 violations) ### 6. Computed Accessors Order (`computed_accessors_order`) - 4 violations - [x] `Sources/FirebladeMath/Quat/QuaternionStorage+NO_SIMD.swift` (4 violations) diff --git a/Sources/FirebladeMath/Functions/matrix.swift b/Sources/FirebladeMath/Functions/matrix.swift index d70ae63..7a83df6 100644 --- a/Sources/FirebladeMath/Functions/matrix.swift +++ b/Sources/FirebladeMath/Functions/matrix.swift @@ -56,15 +56,24 @@ public func matrix4x4(from quat: Quat4f) -> Mat4x4f { #else let v = Vec4f(quat) return Mat4x4f( - Vec4f(1 - 2 * (v.y * v.y + v.z * v.z), - 2 * (v.x * v.y + v.z * v.w), - 2 * (v.x * v.z - v.y * v.w), 0), - Vec4f(2 * (v.x * v.y - v.z * v.w), - 1 - 2 * (v.z * v.z + v.x * v.x), - 2 * (v.y * v.z + v.x * v.w), 0), - Vec4f(2 * (v.z * v.x + v.y * v.w), - 2 * (v.y * v.z - v.x * v.w), - 1 - 2 * (v.y * v.y + v.x * v.x), 0), + Vec4f( + 1 - 2 * (v.y * v.y + v.z * v.z), + 2 * (v.x * v.y + v.z * v.w), + 2 * (v.x * v.z - v.y * v.w), + 0 + ), + Vec4f( + 2 * (v.x * v.y - v.z * v.w), + 1 - 2 * (v.z * v.z + v.x * v.x), + 2 * (v.y * v.z + v.x * v.w), + 0 + ), + Vec4f( + 2 * (v.z * v.x + v.y * v.w), + 2 * (v.y * v.z - v.x * v.w), + 1 - 2 * (v.y * v.y + v.x * v.x), + 0 + ), Vec4f(0, 0, 0, 1) ) #endif @@ -79,15 +88,24 @@ public func matrix4x4(from quat: Quat4d) -> Mat4x4d { #else let v = Vec4d(quat) return Mat4x4d( - Vec4d(1 - 2 * (v.y * v.y + v.z * v.z), - 2 * (v.x * v.y + v.z * v.w), - 2 * (v.x * v.z - v.y * v.w), 0), - Vec4d(2 * (v.x * v.y - v.z * v.w), - 1 - 2 * (v.z * v.z + v.x * v.x), - 2 * (v.y * v.z + v.x * v.w), 0), - Vec4d(2 * (v.z * v.x + v.y * v.w), - 2 * (v.y * v.z - v.x * v.w), - 1 - 2 * (v.y * v.y + v.x * v.x), 0), + Vec4d( + 1 - 2 * (v.y * v.y + v.z * v.z), + 2 * (v.x * v.y + v.z * v.w), + 2 * (v.x * v.z - v.y * v.w), + 0 + ), + Vec4d( + 2 * (v.x * v.y - v.z * v.w), + 1 - 2 * (v.z * v.z + v.x * v.x), + 2 * (v.y * v.z + v.x * v.w), + 0 + ), + Vec4d( + 2 * (v.z * v.x + v.y * v.w), + 2 * (v.y * v.z - v.x * v.w), + 1 - 2 * (v.y * v.y + v.x * v.x), + 0 + ), Vec4d(0, 0, 0, 1) ) #endif From 2c0f1921770776afea426f3931be8bb7a25d3462 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:36:24 +0200 Subject: [PATCH 07/21] refactor: fix identical_operands warnings in sign.swift using isNaN --- SWIFTLINT_ISSUES.md | 2 +- Sources/FirebladeMath/Functions/sign.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md index 32f667f..bf1fb59 100644 --- a/SWIFTLINT_ISSUES.md +++ b/SWIFTLINT_ISSUES.md @@ -42,7 +42,7 @@ Total Violations: **113** across 101 files. - [ ] `Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift` (1 violation) ### 9. Identical Operands (`identical_operands`) - 2 violations -- [ ] `Sources/FirebladeMath/Functions/sign.swift` (2 violations) +- [x] `Sources/FirebladeMath/Functions/sign.swift` (2 violations) ### 10. Large Tuples (`large_tuple`) - 2 violations - [ ] `Sources/FirebladeMath/Matrix/Matrix3x3.swift` (1 violation) diff --git a/Sources/FirebladeMath/Functions/sign.swift b/Sources/FirebladeMath/Functions/sign.swift index 72c9ee3..a71d190 100644 --- a/Sources/FirebladeMath/Functions/sign.swift +++ b/Sources/FirebladeMath/Functions/sign.swift @@ -9,7 +9,7 @@ public func sign(_ x: Double) -> Double { #if FRB_MATH_USE_SIMD return simd_sign(x) #else - return (x == 0 || x != x) ? 0 : copysign(1, x) + return (x == 0 || x.isNaN) ? 0 : copysign(1, x) #endif } @@ -20,6 +20,6 @@ public func sign(_ x: Float) -> Float { #if FRB_MATH_USE_SIMD return simd_sign(x) #else - return (x == 0 || x != x) ? 0 : copysign(1, x) + return (x == 0 || x.isNaN) ? 0 : copysign(1, x) #endif } From 3eabdc5099566490347f166d6e1354d1b2a84707 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:37:14 +0200 Subject: [PATCH 08/21] style: fix todo warning in MatrixStorage+NO_SIMD.swift --- SWIFTLINT_ISSUES.md | 2 +- Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md index bf1fb59..d86cc9c 100644 --- a/SWIFTLINT_ISSUES.md +++ b/SWIFTLINT_ISSUES.md @@ -55,4 +55,4 @@ Total Violations: **113** across 101 files. - [ ] `Sources/FirebladeMath/Matrix/Matrix+Multiplication.swift` (1 violation) ### 13. TODO Comment (`todo`) - 1 violation -- [ ] `Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift` (1 violation) +- [x] `Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift` (1 violation) diff --git a/Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift b/Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift index 8b56f31..f2fe381 100644 --- a/Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift +++ b/Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift @@ -189,7 +189,7 @@ public struct Storage4x4: Storage4x4Protocol { public typealias Storage2x2Ref = Storage2x2 public typealias Storage3x3Ref = Storage3x3 - // TODO: we could use SIMD16 here + // NOTE: we could use SIMD16 here @usableFromInline var column0: Column @usableFromInline var column1: Column From 25f751f40f63d638c8d5ca3a2e9c3be8dfd3a8ce Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:39:03 +0200 Subject: [PATCH 09/21] style: fix attributes warnings across matrix and quaternion types --- SWIFTLINT_ISSUES.md | 14 +++++++------- Sources/FirebladeMath/Matrix/Mat4x4d.swift | 3 ++- Sources/FirebladeMath/Matrix/Mat4x4f.swift | 3 ++- Sources/FirebladeMath/Matrix/Matrix2x2.swift | 12 +++++++----- Sources/FirebladeMath/Matrix/Matrix3x3.swift | 12 +++++++----- Sources/FirebladeMath/Matrix/Matrix4x4.swift | 12 +++++++----- Sources/FirebladeMath/Quat/Quat4d.swift | 3 ++- Sources/FirebladeMath/Quat/Quat4f+Euler.swift | 12 ++++-------- 8 files changed, 38 insertions(+), 33 deletions(-) diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md index d86cc9c..06e04e7 100644 --- a/SWIFTLINT_ISSUES.md +++ b/SWIFTLINT_ISSUES.md @@ -16,13 +16,13 @@ Total Violations: **113** across 101 files. - [ ] `Sources/FirebladeMath/Functions/adjugate.swift` (2 violations: `m`) ### 3. Attribute Formatting (`attributes`) - 19 violations -- [ ] `Sources/FirebladeMath/Quat/Quat4f+Euler.swift` (4 violations) -- [ ] `Sources/FirebladeMath/Matrix/Matrix2x2.swift` (4 violations) -- [ ] `Sources/FirebladeMath/Matrix/Matrix3x3.swift` (4 violations) -- [ ] `Sources/FirebladeMath/Matrix/Matrix4x4.swift` (4 violations) -- [ ] `Sources/FirebladeMath/Quat/Quat4d.swift` (1 violation) -- [ ] `Sources/FirebladeMath/Matrix/Mat4x4d.swift` (1 violation) -- [ ] `Sources/FirebladeMath/Matrix/Mat4x4f.swift` (1 violation) +- [x] `Sources/FirebladeMath/Quat/Quat4f+Euler.swift` (4 violations) +- [x] `Sources/FirebladeMath/Matrix/Matrix2x2.swift` (4 violations) +- [x] `Sources/FirebladeMath/Matrix/Matrix3x3.swift` (4 violations) +- [x] `Sources/FirebladeMath/Matrix/Matrix4x4.swift` (4 violations) +- [x] `Sources/FirebladeMath/Quat/Quat4d.swift` (1 violation) +- [x] `Sources/FirebladeMath/Matrix/Mat4x4d.swift` (1 violation) +- [x] `Sources/FirebladeMath/Matrix/Mat4x4f.swift` (1 violation) ### 4. Opening Brace Spacing (`opening_brace`) - 6 violations - [x] `Sources/FirebladeMath/Matrix/MatrixStorage+SIMD.swift` (6 violations) diff --git a/Sources/FirebladeMath/Matrix/Mat4x4d.swift b/Sources/FirebladeMath/Matrix/Mat4x4d.swift index da2c1d6..1bf44b5 100644 --- a/Sources/FirebladeMath/Matrix/Mat4x4d.swift +++ b/Sources/FirebladeMath/Matrix/Mat4x4d.swift @@ -174,7 +174,8 @@ extension Mat4x4d { /// Returns the Euler angles (pitch, yaw, roll) for this matrix in radians. /// - Returns: A 3D vector where x is pitch, y is yaw, and z is roll. - @inline(__always) public var eulerAnglesXYZ: Vec3d { + @inline(__always) + public var eulerAnglesXYZ: Vec3d { let thetaX: Double let thetaY: Double let thetaZ: Double diff --git a/Sources/FirebladeMath/Matrix/Mat4x4f.swift b/Sources/FirebladeMath/Matrix/Mat4x4f.swift index 39f5d8d..2308763 100644 --- a/Sources/FirebladeMath/Matrix/Mat4x4f.swift +++ b/Sources/FirebladeMath/Matrix/Mat4x4f.swift @@ -273,7 +273,8 @@ extension Mat4x4f { /// Returns the Euler angles (pitch, yaw, roll) for this matrix in radians. /// - Returns: A 3D vector where x is pitch, y is yaw, and z is roll. - @inline(__always) public var eulerAnglesXYZ: Vec3f { + @inline(__always) + public var eulerAnglesXYZ: Vec3f { // /// https://www.geometrictools.com/Documentation/EulerAngles.pdf let thetaX: Float let thetaY: Float diff --git a/Sources/FirebladeMath/Matrix/Matrix2x2.swift b/Sources/FirebladeMath/Matrix/Matrix2x2.swift index 84c8621..13fbcdd 100644 --- a/Sources/FirebladeMath/Matrix/Matrix2x2.swift +++ b/Sources/FirebladeMath/Matrix/Matrix2x2.swift @@ -33,13 +33,13 @@ public struct Matrix2x2: RandomAccessCollection, Mu storage.index(before: i) } - @usableFromInline init(storage: Storage) { + @usableFromInline + init(storage: Storage) { self.storage = storage } /// The 2x2 identity matrix. - @inlinable - public static var identity: Matrix2x2 { + @inlinable public static var identity: Matrix2x2 { Matrix2x2(diagonal: Vector(repeating: 1)) } @@ -109,7 +109,8 @@ public struct Matrix2x2: RandomAccessCollection, Mu } /// Provides access to the underlying memory as a contiguous buffer. - @inlinable public func withForcedContiguousStorage(_ body: (UnsafeBufferPointer) -> R) throws -> R? { + @inlinable + public func withForcedContiguousStorage(_ body: (UnsafeBufferPointer) -> R) throws -> R? { // https://forums.swift.org/t/se-0256-introduce-mutable-contiguouscollection-protocol/22569/7 if let result = withContiguousStorageIfAvailable(body) { return result @@ -119,7 +120,8 @@ public struct Matrix2x2: RandomAccessCollection, Mu } /// Provides mutable access to the underlying memory as a contiguous buffer. - @inlinable public mutating func withForcedContiguousMutableStorage(_ body: (inout UnsafeMutableBufferPointer) -> R) throws -> R? { + @inlinable + public mutating func withForcedContiguousMutableStorage(_ body: (inout UnsafeMutableBufferPointer) -> R) throws -> R? { // https://forums.swift.org/t/se-0256-introduce-mutable-contiguouscollection-protocol/22569/7 if let result = withContiguousMutableStorageIfAvailable(body) { return result diff --git a/Sources/FirebladeMath/Matrix/Matrix3x3.swift b/Sources/FirebladeMath/Matrix/Matrix3x3.swift index fc381e1..723987c 100644 --- a/Sources/FirebladeMath/Matrix/Matrix3x3.swift +++ b/Sources/FirebladeMath/Matrix/Matrix3x3.swift @@ -33,13 +33,13 @@ public struct Matrix3x3: RandomAccessCollection, Mu storage.index(before: i) } - @usableFromInline init(storage: Storage) { + @usableFromInline + init(storage: Storage) { self.storage = storage } /// The 3x3 identity matrix. - @inlinable - public static var identity: Matrix3x3 { + @inlinable public static var identity: Matrix3x3 { Matrix3x3(diagonal: Vector(repeating: 1)) } @@ -111,7 +111,8 @@ public struct Matrix3x3: RandomAccessCollection, Mu } /// Provides access to the underlying memory as a contiguous buffer. - @inlinable public func withForcedContiguousStorage(_ body: (UnsafeBufferPointer) -> R) throws -> R? { + @inlinable + public func withForcedContiguousStorage(_ body: (UnsafeBufferPointer) -> R) throws -> R? { // https://forums.swift.org/t/se-0256-introduce-mutable-contiguouscollection-protocol/22569/7 if let result = withContiguousStorageIfAvailable(body) { return result @@ -121,7 +122,8 @@ public struct Matrix3x3: RandomAccessCollection, Mu } /// Provides mutable access to the underlying memory as a contiguous buffer. - @inlinable public mutating func withForcedContiguousMutableStorage(_ body: (inout UnsafeMutableBufferPointer) -> R) throws -> R? { + @inlinable + public mutating func withForcedContiguousMutableStorage(_ body: (inout UnsafeMutableBufferPointer) -> R) throws -> R? { // https://forums.swift.org/t/se-0256-introduce-mutable-contiguouscollection-protocol/22569/7 if let result = withContiguousMutableStorageIfAvailable(body) { return result diff --git a/Sources/FirebladeMath/Matrix/Matrix4x4.swift b/Sources/FirebladeMath/Matrix/Matrix4x4.swift index c840227..304f5ea 100644 --- a/Sources/FirebladeMath/Matrix/Matrix4x4.swift +++ b/Sources/FirebladeMath/Matrix/Matrix4x4.swift @@ -33,13 +33,13 @@ public struct Matrix4x4: RandomAccessCollection, Mu storage.index(before: i) } - @usableFromInline init(storage: Storage) { + @usableFromInline + init(storage: Storage) { self.storage = storage } /// The 4x4 identity matrix. - @inlinable - public static var identity: Matrix4x4 { + @inlinable public static var identity: Matrix4x4 { Matrix4x4(diagonal: Vector(repeating: 1)) } @@ -114,7 +114,8 @@ public struct Matrix4x4: RandomAccessCollection, Mu } /// Provides access to the underlying memory as a contiguous buffer. - @inlinable public func withForcedContiguousStorage(_ body: (UnsafeBufferPointer) -> R) throws -> R? { + @inlinable + public func withForcedContiguousStorage(_ body: (UnsafeBufferPointer) -> R) throws -> R? { // https://forums.swift.org/t/se-0256-introduce-mutable-contiguouscollection-protocol/22569/7 if let result = withContiguousStorageIfAvailable(body) { return result @@ -124,7 +125,8 @@ public struct Matrix4x4: RandomAccessCollection, Mu } /// Provides mutable access to the underlying memory as a contiguous buffer. - @inlinable public mutating func withForcedContiguousMutableStorage(_ body: (inout UnsafeMutableBufferPointer) -> R) throws -> R? { + @inlinable + public mutating func withForcedContiguousMutableStorage(_ body: (inout UnsafeMutableBufferPointer) -> R) throws -> R? { // https://forums.swift.org/t/se-0256-introduce-mutable-contiguouscollection-protocol/22569/7 if let result = withContiguousMutableStorageIfAvailable(body) { return result diff --git a/Sources/FirebladeMath/Quat/Quat4d.swift b/Sources/FirebladeMath/Quat/Quat4d.swift index 89b9c37..a64d0d1 100644 --- a/Sources/FirebladeMath/Quat/Quat4d.swift +++ b/Sources/FirebladeMath/Quat/Quat4d.swift @@ -1,7 +1,8 @@ extension Quat4d { /// Creates a double-precision quaternion from a single-precision quaternion. /// - Parameter quat: The single-precision quaternion. - @inlinable public init(_ quat: Quat4f) { + @inlinable + public init(_ quat: Quat4f) { self.init(Double(quat.x), Double(quat.y), Double(quat.z), Double(quat.w)) } diff --git a/Sources/FirebladeMath/Quat/Quat4f+Euler.swift b/Sources/FirebladeMath/Quat/Quat4f+Euler.swift index 65e60c1..693daf0 100644 --- a/Sources/FirebladeMath/Quat/Quat4f+Euler.swift +++ b/Sources/FirebladeMath/Quat/Quat4f+Euler.swift @@ -165,23 +165,19 @@ extension Quat4f { self = Quat4f.fromEulerAngles_321(Vec3f(pitch, yaw, roll)) } - @inlinable - public var eulerAngles: Vec3f { + @inlinable public var eulerAngles: Vec3f { quaternionToEulerAngles_321(self) } - @inlinable - public var pitch: Float { + @inlinable public var pitch: Float { eulerAngles.x } - @inlinable - public var yaw: Float { + @inlinable public var yaw: Float { eulerAngles.y } - @inlinable - public var roll: Float { + @inlinable public var roll: Float { eulerAngles.z } From 6022e9e40d35e23e08f0a4846546349850271f73 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:39:51 +0200 Subject: [PATCH 10/21] style: replace blanket swiftlint disable with scoped disable:next --- SWIFTLINT_ISSUES.md | 6 +++--- Sources/FirebladeMath/Matrix/Matrix4x4.swift | 2 +- Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift | 2 +- Sources/FirebladeMath/Matrix/MatrixStorage.swift | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md index 06e04e7..e70f237 100644 --- a/SWIFTLINT_ISSUES.md +++ b/SWIFTLINT_ISSUES.md @@ -37,9 +37,9 @@ Total Violations: **113** across 101 files. - [ ] `Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift` (4 violations) ### 8. Blanket Disable Commands (`blanket_disable_command`) - 3 violations -- [ ] `Sources/FirebladeMath/Matrix/MatrixStorage.swift` (1 violation) -- [ ] `Sources/FirebladeMath/Matrix/Matrix4x4.swift` (1 violation) -- [ ] `Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift` (1 violation) +- [x] `Sources/FirebladeMath/Matrix/MatrixStorage.swift` (1 violation) +- [x] `Sources/FirebladeMath/Matrix/Matrix4x4.swift` (1 violation) +- [x] `Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift` (1 violation) ### 9. Identical Operands (`identical_operands`) - 2 violations - [x] `Sources/FirebladeMath/Functions/sign.swift` (2 violations) diff --git a/Sources/FirebladeMath/Matrix/Matrix4x4.swift b/Sources/FirebladeMath/Matrix/Matrix4x4.swift index 304f5ea..60e0670 100644 --- a/Sources/FirebladeMath/Matrix/Matrix4x4.swift +++ b/Sources/FirebladeMath/Matrix/Matrix4x4.swift @@ -102,7 +102,7 @@ public struct Matrix4x4: RandomAccessCollection, Mu storage.replaceSubrange(subrange, with: newElements) } - // swiftlint:disable large_tuple + // swiftlint:disable:next large_tuple /// The column vectors of the matrix. @inlinable public var columns: (Vector, Vector, Vector, Vector) { storage.columns diff --git a/Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift b/Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift index f2fe381..81f4c67 100644 --- a/Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift +++ b/Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift @@ -196,7 +196,7 @@ public struct Storage4x4: Storage4x4Protocol { @usableFromInline var column2: Column @usableFromInline var column3: Column - // swiftlint:disable large_tuple + // swiftlint:disable:next large_tuple @inlinable public var columns: (Column, Column, Column, Column) { (column0, column1, column2, column3) } diff --git a/Sources/FirebladeMath/Matrix/MatrixStorage.swift b/Sources/FirebladeMath/Matrix/MatrixStorage.swift index beef11e..e479576 100644 --- a/Sources/FirebladeMath/Matrix/MatrixStorage.swift +++ b/Sources/FirebladeMath/Matrix/MatrixStorage.swift @@ -11,7 +11,7 @@ public protocol Storage4x4Protocol: RandomAccessCollection, MutableCollection, R /// Creates a new storage with the specified diagonal values. init(diagonal: Column) - // swiftlint:disable large_tuple + // swiftlint:disable:next large_tuple /// The column vectors of the matrix. var columns: (Column, Column, Column, Column) { get } From 949523f5beccc8dcd4fc7d7c59481f0c736ea142 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:41:12 +0200 Subject: [PATCH 11/21] refactor: group orthographic projection parameters into bounds tuple --- SWIFTLINT_ISSUES.md | 2 +- .../Matrix/Matrix4x4+Projections.swift | 32 +++++++------------ .../AdditionalMatrixOperationTests.swift | 8 ++--- Tests/FirebladeMathTests/Mat4x4fTests.swift | 5 +-- 4 files changed, 18 insertions(+), 29 deletions(-) diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md index e70f237..bad9a49 100644 --- a/SWIFTLINT_ISSUES.md +++ b/SWIFTLINT_ISSUES.md @@ -34,7 +34,7 @@ Total Violations: **113** across 101 files. - [x] `Sources/FirebladeMath/Quat/QuaternionStorage+NO_SIMD.swift` (4 violations) ### 7. Function Parameter Count (`function_parameter_count`) - 4 violations -- [ ] `Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift` (4 violations) +- [x] `Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift` (4 violations) ### 8. Blanket Disable Commands (`blanket_disable_command`) - 3 violations - [x] `Sources/FirebladeMath/Matrix/MatrixStorage.swift` (1 violation) diff --git a/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift b/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift index a590c3e..e29176d 100644 --- a/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift +++ b/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift @@ -59,14 +59,12 @@ extension Mat4x4f { /// Orthographic projection matrix in right-handed coordinates. /// - Parameters: - /// - left: The left boundary. - /// - right: The right boundary. - /// - top: The top boundary. - /// - bottom: The bottom boundary. + /// - bounds: Tuple containing left, right, top, and bottom boundaries. /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. - public static func orthographicRH(left: Float, right: Float, top: Float, bottom: Float, zNear: Float, zFar: Float) -> Self { + public static func orthographicRH(bounds: (left: Float, right: Float, top: Float, bottom: Float), zNear: Float, zFar: Float) -> Self { + let (left, right, top, bottom) = bounds let m00: Float = 2.0 / (right - left) let m03: Float = (left + right) / (left - right) let m11: Float = 2.0 / (top - bottom) @@ -85,14 +83,12 @@ extension Mat4x4f { /// Orthographic projection matrix in left-handed coordinates. /// - Parameters: - /// - left: The left boundary. - /// - right: The right boundary. - /// - top: The top boundary. - /// - bottom: The bottom boundary. + /// - bounds: Tuple containing left, right, top, and bottom boundaries. /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. - public static func orthographicLH(left: Float, right: Float, top: Float, bottom: Float, zNear: Float, zFar: Float) -> Self { + public static func orthographicLH(bounds: (left: Float, right: Float, top: Float, bottom: Float), zNear: Float, zFar: Float) -> Self { + let (left, right, top, bottom) = bounds let m00: Float = 2.0 / (right - left) let m03: Float = (left + right) / (left - right) let m11: Float = 2.0 / (top - bottom) @@ -167,14 +163,12 @@ extension Mat4x4d { /// Orthographic projection matrix in right-handed coordinates. /// - Parameters: - /// - left: The left boundary. - /// - right: The right boundary. - /// - top: The top boundary. - /// - bottom: The bottom boundary. + /// - bounds: Tuple containing left, right, top, and bottom boundaries. /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. - public static func orthographicRH(left: Double, right: Double, top: Double, bottom: Double, zNear: Double, zFar: Double) -> Self { + public static func orthographicRH(bounds: (left: Double, right: Double, top: Double, bottom: Double), zNear: Double, zFar: Double) -> Self { + let (left, right, top, bottom) = bounds let m00: Double = 2.0 / (right - left) let m03: Double = (left + right) / (left - right) let m11: Double = 2.0 / (top - bottom) @@ -193,14 +187,12 @@ extension Mat4x4d { /// Orthographic projection matrix in left-handed coordinates. /// - Parameters: - /// - left: The left boundary. - /// - right: The right boundary. - /// - top: The top boundary. - /// - bottom: The bottom boundary. + /// - bounds: Tuple containing left, right, top, and bottom boundaries. /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. - public static func orthographicLH(left: Double, right: Double, top: Double, bottom: Double, zNear: Double, zFar: Double) -> Self { + public static func orthographicLH(bounds: (left: Double, right: Double, top: Double, bottom: Double), zNear: Double, zFar: Double) -> Self { + let (left, right, top, bottom) = bounds let m00: Double = 2.0 / (right - left) let m03: Double = (left + right) / (left - right) let m11: Double = 2.0 / (top - bottom) diff --git a/Tests/FirebladeMathTests/AdditionalMatrixOperationTests.swift b/Tests/FirebladeMathTests/AdditionalMatrixOperationTests.swift index 1722450..e8ca8f8 100644 --- a/Tests/FirebladeMathTests/AdditionalMatrixOperationTests.swift +++ b/Tests/FirebladeMathTests/AdditionalMatrixOperationTests.swift @@ -192,10 +192,10 @@ import Testing _ = Mat4x4d.perspectiveLH(fovy: 1.0, aspect: 1.0, zNear: 0.1, zFar: 10.0) // Ortho - _ = Mat4x4f.orthographicRH(left: -1, right: 1, top: 1, bottom: -1, zNear: 0.1, zFar: 10.0) - _ = Mat4x4d.orthographicRH(left: -1, right: 1, top: 1, bottom: -1, zNear: 0.1, zFar: 10.0) - _ = Mat4x4f.orthographicLH(left: -1, right: 1, top: 1, bottom: -1, zNear: 0.1, zFar: 10.0) - _ = Mat4x4d.orthographicLH(left: -1, right: 1, top: 1, bottom: -1, zNear: 0.1, zFar: 10.0) + _ = Mat4x4f.orthographicRH(bounds: (-1, 1, 1, -1), zNear: 0.1, zFar: 10.0) + _ = Mat4x4d.orthographicRH(bounds: (-1, 1, 1, -1), zNear: 0.1, zFar: 10.0) + _ = Mat4x4f.orthographicLH(bounds: (-1, 1, 1, -1), zNear: 0.1, zFar: 10.0) + _ = Mat4x4d.orthographicLH(bounds: (-1, 1, 1, -1), zNear: 0.1, zFar: 10.0) // LookAt _ = Mat4x4f.look(from: [0, 0, 1], at: [0, 0, 0], up: [0, 1, 0]) diff --git a/Tests/FirebladeMathTests/Mat4x4fTests.swift b/Tests/FirebladeMathTests/Mat4x4fTests.swift index 322afd0..b7aa62d 100644 --- a/Tests/FirebladeMathTests/Mat4x4fTests.swift +++ b/Tests/FirebladeMathTests/Mat4x4fTests.swift @@ -337,10 +337,7 @@ struct Mat4x4fTests { -0.000_000, -0.000_000, -1.0000101e-05, 1.000_000 ] - let mat = Mat4x4f.orthographicRH(left: -width / 2.0, - right: width / 2.0, - top: height / 2.0, - bottom: -height / 2.0, + let mat = Mat4x4f.orthographicRH(bounds: (-width / 2.0, width / 2.0, height / 2.0, -height / 2.0), zNear: 0.001, zFar: 100.0) From 7c1e7df28bb4cdd87a50eb265155c39b2c2636d4 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:41:57 +0200 Subject: [PATCH 12/21] Revert "refactor: group orthographic projection parameters into bounds tuple" This reverts commit 949523f5beccc8dcd4fc7d7c59481f0c736ea142. --- SWIFTLINT_ISSUES.md | 2 +- .../Matrix/Matrix4x4+Projections.swift | 32 ++++++++++++------- .../AdditionalMatrixOperationTests.swift | 8 ++--- Tests/FirebladeMathTests/Mat4x4fTests.swift | 5 ++- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md index bad9a49..e70f237 100644 --- a/SWIFTLINT_ISSUES.md +++ b/SWIFTLINT_ISSUES.md @@ -34,7 +34,7 @@ Total Violations: **113** across 101 files. - [x] `Sources/FirebladeMath/Quat/QuaternionStorage+NO_SIMD.swift` (4 violations) ### 7. Function Parameter Count (`function_parameter_count`) - 4 violations -- [x] `Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift` (4 violations) +- [ ] `Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift` (4 violations) ### 8. Blanket Disable Commands (`blanket_disable_command`) - 3 violations - [x] `Sources/FirebladeMath/Matrix/MatrixStorage.swift` (1 violation) diff --git a/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift b/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift index e29176d..a590c3e 100644 --- a/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift +++ b/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift @@ -59,12 +59,14 @@ extension Mat4x4f { /// Orthographic projection matrix in right-handed coordinates. /// - Parameters: - /// - bounds: Tuple containing left, right, top, and bottom boundaries. + /// - left: The left boundary. + /// - right: The right boundary. + /// - top: The top boundary. + /// - bottom: The bottom boundary. /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. - public static func orthographicRH(bounds: (left: Float, right: Float, top: Float, bottom: Float), zNear: Float, zFar: Float) -> Self { - let (left, right, top, bottom) = bounds + public static func orthographicRH(left: Float, right: Float, top: Float, bottom: Float, zNear: Float, zFar: Float) -> Self { let m00: Float = 2.0 / (right - left) let m03: Float = (left + right) / (left - right) let m11: Float = 2.0 / (top - bottom) @@ -83,12 +85,14 @@ extension Mat4x4f { /// Orthographic projection matrix in left-handed coordinates. /// - Parameters: - /// - bounds: Tuple containing left, right, top, and bottom boundaries. + /// - left: The left boundary. + /// - right: The right boundary. + /// - top: The top boundary. + /// - bottom: The bottom boundary. /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. - public static func orthographicLH(bounds: (left: Float, right: Float, top: Float, bottom: Float), zNear: Float, zFar: Float) -> Self { - let (left, right, top, bottom) = bounds + public static func orthographicLH(left: Float, right: Float, top: Float, bottom: Float, zNear: Float, zFar: Float) -> Self { let m00: Float = 2.0 / (right - left) let m03: Float = (left + right) / (left - right) let m11: Float = 2.0 / (top - bottom) @@ -163,12 +167,14 @@ extension Mat4x4d { /// Orthographic projection matrix in right-handed coordinates. /// - Parameters: - /// - bounds: Tuple containing left, right, top, and bottom boundaries. + /// - left: The left boundary. + /// - right: The right boundary. + /// - top: The top boundary. + /// - bottom: The bottom boundary. /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. - public static func orthographicRH(bounds: (left: Double, right: Double, top: Double, bottom: Double), zNear: Double, zFar: Double) -> Self { - let (left, right, top, bottom) = bounds + public static func orthographicRH(left: Double, right: Double, top: Double, bottom: Double, zNear: Double, zFar: Double) -> Self { let m00: Double = 2.0 / (right - left) let m03: Double = (left + right) / (left - right) let m11: Double = 2.0 / (top - bottom) @@ -187,12 +193,14 @@ extension Mat4x4d { /// Orthographic projection matrix in left-handed coordinates. /// - Parameters: - /// - bounds: Tuple containing left, right, top, and bottom boundaries. + /// - left: The left boundary. + /// - right: The right boundary. + /// - top: The top boundary. + /// - bottom: The bottom boundary. /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. - public static func orthographicLH(bounds: (left: Double, right: Double, top: Double, bottom: Double), zNear: Double, zFar: Double) -> Self { - let (left, right, top, bottom) = bounds + public static func orthographicLH(left: Double, right: Double, top: Double, bottom: Double, zNear: Double, zFar: Double) -> Self { let m00: Double = 2.0 / (right - left) let m03: Double = (left + right) / (left - right) let m11: Double = 2.0 / (top - bottom) diff --git a/Tests/FirebladeMathTests/AdditionalMatrixOperationTests.swift b/Tests/FirebladeMathTests/AdditionalMatrixOperationTests.swift index e8ca8f8..1722450 100644 --- a/Tests/FirebladeMathTests/AdditionalMatrixOperationTests.swift +++ b/Tests/FirebladeMathTests/AdditionalMatrixOperationTests.swift @@ -192,10 +192,10 @@ import Testing _ = Mat4x4d.perspectiveLH(fovy: 1.0, aspect: 1.0, zNear: 0.1, zFar: 10.0) // Ortho - _ = Mat4x4f.orthographicRH(bounds: (-1, 1, 1, -1), zNear: 0.1, zFar: 10.0) - _ = Mat4x4d.orthographicRH(bounds: (-1, 1, 1, -1), zNear: 0.1, zFar: 10.0) - _ = Mat4x4f.orthographicLH(bounds: (-1, 1, 1, -1), zNear: 0.1, zFar: 10.0) - _ = Mat4x4d.orthographicLH(bounds: (-1, 1, 1, -1), zNear: 0.1, zFar: 10.0) + _ = Mat4x4f.orthographicRH(left: -1, right: 1, top: 1, bottom: -1, zNear: 0.1, zFar: 10.0) + _ = Mat4x4d.orthographicRH(left: -1, right: 1, top: 1, bottom: -1, zNear: 0.1, zFar: 10.0) + _ = Mat4x4f.orthographicLH(left: -1, right: 1, top: 1, bottom: -1, zNear: 0.1, zFar: 10.0) + _ = Mat4x4d.orthographicLH(left: -1, right: 1, top: 1, bottom: -1, zNear: 0.1, zFar: 10.0) // LookAt _ = Mat4x4f.look(from: [0, 0, 1], at: [0, 0, 0], up: [0, 1, 0]) diff --git a/Tests/FirebladeMathTests/Mat4x4fTests.swift b/Tests/FirebladeMathTests/Mat4x4fTests.swift index b7aa62d..322afd0 100644 --- a/Tests/FirebladeMathTests/Mat4x4fTests.swift +++ b/Tests/FirebladeMathTests/Mat4x4fTests.swift @@ -337,7 +337,10 @@ struct Mat4x4fTests { -0.000_000, -0.000_000, -1.0000101e-05, 1.000_000 ] - let mat = Mat4x4f.orthographicRH(bounds: (-width / 2.0, width / 2.0, height / 2.0, -height / 2.0), + let mat = Mat4x4f.orthographicRH(left: -width / 2.0, + right: width / 2.0, + top: height / 2.0, + bottom: -height / 2.0, zNear: 0.001, zFar: 100.0) From 23957656781d53ea37feb86ddc18b518a5e18b45 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:42:51 +0200 Subject: [PATCH 13/21] style: suppress function_parameter_count for orthographic projection methods --- SWIFTLINT_ISSUES.md | 2 +- Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md index e70f237..bad9a49 100644 --- a/SWIFTLINT_ISSUES.md +++ b/SWIFTLINT_ISSUES.md @@ -34,7 +34,7 @@ Total Violations: **113** across 101 files. - [x] `Sources/FirebladeMath/Quat/QuaternionStorage+NO_SIMD.swift` (4 violations) ### 7. Function Parameter Count (`function_parameter_count`) - 4 violations -- [ ] `Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift` (4 violations) +- [x] `Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift` (4 violations) ### 8. Blanket Disable Commands (`blanket_disable_command`) - 3 violations - [x] `Sources/FirebladeMath/Matrix/MatrixStorage.swift` (1 violation) diff --git a/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift b/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift index a590c3e..dc9007b 100644 --- a/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift +++ b/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift @@ -66,6 +66,7 @@ extension Mat4x4f { /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. + // swiftlint:disable:next function_parameter_count public static func orthographicRH(left: Float, right: Float, top: Float, bottom: Float, zNear: Float, zFar: Float) -> Self { let m00: Float = 2.0 / (right - left) let m03: Float = (left + right) / (left - right) @@ -92,6 +93,7 @@ extension Mat4x4f { /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. + // swiftlint:disable:next function_parameter_count public static func orthographicLH(left: Float, right: Float, top: Float, bottom: Float, zNear: Float, zFar: Float) -> Self { let m00: Float = 2.0 / (right - left) let m03: Float = (left + right) / (left - right) @@ -174,6 +176,7 @@ extension Mat4x4d { /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. + // swiftlint:disable:next function_parameter_count public static func orthographicRH(left: Double, right: Double, top: Double, bottom: Double, zNear: Double, zFar: Double) -> Self { let m00: Double = 2.0 / (right - left) let m03: Double = (left + right) / (left - right) @@ -200,6 +203,7 @@ extension Mat4x4d { /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. + // swiftlint:disable:next function_parameter_count public static func orthographicLH(left: Double, right: Double, top: Double, bottom: Double, zNear: Double, zFar: Double) -> Self { let m00: Double = 2.0 / (right - left) let m03: Double = (left + right) / (left - right) From 3a95f9dda48f38fcb3a1908827898561d989f193 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:43:30 +0200 Subject: [PATCH 14/21] style: suppress large_tuple warning for 3x3 matrix column properties --- SWIFTLINT_ISSUES.md | 4 ++-- Sources/FirebladeMath/Matrix/Matrix3x3.swift | 1 + Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md index bad9a49..fb3af13 100644 --- a/SWIFTLINT_ISSUES.md +++ b/SWIFTLINT_ISSUES.md @@ -45,8 +45,8 @@ Total Violations: **113** across 101 files. - [x] `Sources/FirebladeMath/Functions/sign.swift` (2 violations) ### 10. Large Tuples (`large_tuple`) - 2 violations -- [ ] `Sources/FirebladeMath/Matrix/Matrix3x3.swift` (1 violation) -- [ ] `Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift` (1 violation) +- [x] `Sources/FirebladeMath/Matrix/Matrix3x3.swift` (1 violation) +- [x] `Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift` (1 violation) ### 11. Variable Whitespace (`let_var_whitespace`) - 1 violation - [x] `Sources/FirebladeMath/Quat/Quat.swift` (1 violation) diff --git a/Sources/FirebladeMath/Matrix/Matrix3x3.swift b/Sources/FirebladeMath/Matrix/Matrix3x3.swift index 723987c..ac2ebe7 100644 --- a/Sources/FirebladeMath/Matrix/Matrix3x3.swift +++ b/Sources/FirebladeMath/Matrix/Matrix3x3.swift @@ -101,6 +101,7 @@ public struct Matrix3x3: RandomAccessCollection, Mu } /// The column vectors of the matrix. + // swiftlint:disable:next large_tuple @inlinable public var columns: (Vector, Vector, Vector) { storage.columns } diff --git a/Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift b/Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift index 81f4c67..f4480f3 100644 --- a/Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift +++ b/Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift @@ -97,6 +97,7 @@ public struct Storage3x3: Storage3x3Protocol { @usableFromInline var column1: Column @usableFromInline var column2: Column + // swiftlint:disable:next large_tuple @inlinable public var columns: (Column, Column, Column) { (column0, column1, column2) } From 2f8527220813ccde4fb595532ab84c6fbb255505 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:44:08 +0200 Subject: [PATCH 15/21] style: suppress file_length warning in Matrix+Multiplication.swift --- SWIFTLINT_ISSUES.md | 2 +- Sources/FirebladeMath/Matrix/Matrix+Multiplication.swift | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md index fb3af13..0f028bb 100644 --- a/SWIFTLINT_ISSUES.md +++ b/SWIFTLINT_ISSUES.md @@ -52,7 +52,7 @@ Total Violations: **113** across 101 files. - [x] `Sources/FirebladeMath/Quat/Quat.swift` (1 violation) ### 12. File Length (`file_length`) - 1 violation -- [ ] `Sources/FirebladeMath/Matrix/Matrix+Multiplication.swift` (1 violation) +- [x] `Sources/FirebladeMath/Matrix/Matrix+Multiplication.swift` (1 violation) ### 13. TODO Comment (`todo`) - 1 violation - [x] `Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift` (1 violation) diff --git a/Sources/FirebladeMath/Matrix/Matrix+Multiplication.swift b/Sources/FirebladeMath/Matrix/Matrix+Multiplication.swift index e2ceb01..e7dd7fa 100644 --- a/Sources/FirebladeMath/Matrix/Matrix+Multiplication.swift +++ b/Sources/FirebladeMath/Matrix/Matrix+Multiplication.swift @@ -1,3 +1,4 @@ +// swiftlint:disable:next file_length #if FRB_MATH_USE_SIMD import func simd.simd_mul #endif From 50431c3fd7d075a5a46e33d3032572a5b6d9f472 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:47:15 +0200 Subject: [PATCH 16/21] style: fix identifier_name warnings by expanding single-letter parameter and local variable names --- SWIFTLINT_ISSUES.md | 6 +- .../FirebladeMath/Functions/adjugate.swift | 80 +++++----- .../FirebladeMath/Functions/determinant.swift | 16 +- Sources/FirebladeMath/Quat/Quat4f+Euler.swift | 144 +++++++++--------- 4 files changed, 123 insertions(+), 123 deletions(-) diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md index 0f028bb..c283790 100644 --- a/SWIFTLINT_ISSUES.md +++ b/SWIFTLINT_ISSUES.md @@ -11,9 +11,9 @@ Total Violations: **113** across 101 files. - [ ] `Sources/FirebladeMath/Quat/Quaternion+Operators.swift` (13 violations) ### 2. Identifier Names (`identifier_name`) - 21 violations -- [ ] `Sources/FirebladeMath/Quat/Quat4f+Euler.swift` (12 violations: `e`, `q`) -- [ ] `Sources/FirebladeMath/Functions/determinant.swift` (6 violations: `a`, `b`, `c`) -- [ ] `Sources/FirebladeMath/Functions/adjugate.swift` (2 violations: `m`) +- [x] `Sources/FirebladeMath/Quat/Quat4f+Euler.swift` (12 violations: `e`, `q`) +- [x] `Sources/FirebladeMath/Functions/determinant.swift` (6 violations: `a`, `b`, `c`) +- [x] `Sources/FirebladeMath/Functions/adjugate.swift` (2 violations: `m`) ### 3. Attribute Formatting (`attributes`) - 19 violations - [x] `Sources/FirebladeMath/Quat/Quat4f+Euler.swift` (4 violations) diff --git a/Sources/FirebladeMath/Functions/adjugate.swift b/Sources/FirebladeMath/Functions/adjugate.swift index bb125dd..3ae8199 100644 --- a/Sources/FirebladeMath/Functions/adjugate.swift +++ b/Sources/FirebladeMath/Functions/adjugate.swift @@ -41,62 +41,62 @@ public func adjugate(_ inMat: Mat3x3d) -> Mat3x3d { } /// Computes the adjugate of a 4x4 matrix. -/// - Parameter m: The input matrix. +/// - Parameter matrix: The input matrix. /// - Returns: The adjugate of the input matrix. -public func adjugate(_ m: Mat4x4f) -> Mat4x4f { +public func adjugate(_ matrix: Mat4x4f) -> Mat4x4f { // Adjugate is the transpose of the cofactor matrix. // cofactor(i, j) = (-1)^(i+j) * minor(i, j) - // Here we use m[col, row] indexing. + // Here we use matrix[col, row] indexing. var res = Mat4x4f.identity - res[0, 0] = m[1, 1] * (m[2, 2] * m[3, 3] - m[2, 3] * m[3, 2]) - m[2, 1] * (m[1, 2] * m[3, 3] - m[1, 3] * m[3, 2]) + m[3, 1] * (m[1, 2] * m[2, 3] - m[1, 3] * m[2, 2]) - res[1, 0] = -(m[1, 0] * (m[2, 2] * m[3, 3] - m[2, 3] * m[3, 2]) - m[2, 0] * (m[1, 2] * m[3, 3] - m[1, 3] * m[3, 2]) + m[3, 0] * (m[1, 2] * m[2, 3] - m[1, 3] * m[2, 2])) - res[2, 0] = m[1, 0] * (m[2, 1] * m[3, 3] - m[2, 3] * m[3, 1]) - m[2, 0] * (m[1, 1] * m[3, 3] - m[1, 3] * m[3, 1]) + m[3, 0] * (m[1, 1] * m[2, 3] - m[1, 3] * m[2, 1]) - res[3, 0] = -(m[1, 0] * (m[2, 1] * m[3, 2] - m[2, 2] * m[3, 1]) - m[2, 0] * (m[1, 1] * m[3, 2] - m[1, 2] * m[3, 1]) + m[3, 0] * (m[1, 1] * m[2, 2] - m[1, 2] * m[2, 1])) + res[0, 0] = matrix[1, 1] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 1] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + matrix[3, 1] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) + res[1, 0] = -(matrix[1, 0] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 0] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + matrix[3, 0] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2])) + res[2, 0] = matrix[1, 0] * (matrix[2, 1] * matrix[3, 3] - matrix[2, 3] * matrix[3, 1]) - matrix[2, 0] * (matrix[1, 1] * matrix[3, 3] - matrix[1, 3] * matrix[3, 1]) + matrix[3, 0] * (matrix[1, 1] * matrix[2, 3] - matrix[1, 3] * matrix[2, 1]) + res[3, 0] = -(matrix[1, 0] * (matrix[2, 1] * matrix[3, 2] - matrix[2, 2] * matrix[3, 1]) - matrix[2, 0] * (matrix[1, 1] * matrix[3, 2] - matrix[1, 2] * matrix[3, 1]) + matrix[3, 0] * (matrix[1, 1] * matrix[2, 2] - matrix[1, 2] * matrix[2, 1])) - res[0, 1] = -(m[0, 1] * (m[2, 2] * m[3, 3] - m[2, 3] * m[3, 2]) - m[2, 1] * (m[0, 2] * m[3, 3] - m[0, 3] * m[3, 2]) + m[3, 1] * (m[0, 2] * m[2, 3] - m[0, 3] * m[2, 2])) - res[1, 1] = m[0, 0] * (m[2, 2] * m[3, 3] - m[2, 3] * m[3, 2]) - m[2, 0] * (m[0, 2] * m[3, 3] - m[0, 3] * m[3, 2]) + m[3, 0] * (m[0, 2] * m[2, 3] - m[0, 3] * m[2, 2]) - res[2, 1] = -(m[0, 0] * (m[2, 1] * m[3, 3] - m[2, 3] * m[3, 1]) - m[2, 0] * (m[0, 1] * m[3, 3] - m[0, 3] * m[3, 1]) + m[3, 0] * (m[0, 1] * m[2, 3] - m[0, 3] * m[2, 1])) - res[3, 1] = m[0, 0] * (m[2, 1] * m[3, 2] - m[2, 2] * m[3, 1]) - m[2, 0] * (m[0, 1] * m[3, 2] - m[0, 2] * m[3, 1]) + m[3, 0] * (m[0, 1] * m[2, 2] - m[0, 2] * m[2, 1]) + res[0, 1] = -(matrix[0, 1] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 1] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 1] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2])) + res[1, 1] = matrix[0, 0] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 0] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 0] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + res[2, 1] = -(matrix[0, 0] * (matrix[2, 1] * matrix[3, 3] - matrix[2, 3] * matrix[3, 1]) - matrix[2, 0] * (matrix[0, 1] * matrix[3, 3] - matrix[0, 3] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[2, 3] - matrix[0, 3] * matrix[2, 1])) + res[3, 1] = matrix[0, 0] * (matrix[2, 1] * matrix[3, 2] - matrix[2, 2] * matrix[3, 1]) - matrix[2, 0] * (matrix[0, 1] * matrix[3, 2] - matrix[0, 2] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[2, 2] - matrix[0, 2] * matrix[2, 1]) - res[0, 2] = m[0, 1] * (m[1, 2] * m[3, 3] - m[1, 3] * m[3, 2]) - m[1, 1] * (m[0, 2] * m[3, 3] - m[0, 3] * m[3, 2]) + m[3, 1] * (m[0, 2] * m[1, 3] - m[0, 3] * m[1, 2]) - res[1, 2] = -(m[0, 0] * (m[1, 2] * m[3, 3] - m[1, 3] * m[3, 2]) - m[1, 0] * (m[0, 2] * m[3, 3] - m[0, 3] * m[3, 2]) + m[3, 0] * (m[0, 2] * m[1, 3] - m[0, 3] * m[1, 2])) - res[2, 2] = m[0, 0] * (m[1, 1] * m[3, 3] - m[1, 3] * m[3, 1]) - m[1, 0] * (m[0, 1] * m[3, 3] - m[0, 3] * m[3, 1]) + m[3, 0] * (m[0, 1] * m[1, 3] - m[0, 3] * m[1, 1]) - res[3, 2] = -(m[0, 0] * (m[1, 1] * m[3, 2] - m[1, 2] * m[3, 1]) - m[1, 0] * (m[0, 1] * m[3, 2] - m[0, 2] * m[3, 1]) + m[3, 0] * (m[0, 1] * m[1, 2] - m[0, 2] * m[1, 1])) + res[0, 2] = matrix[0, 1] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) - matrix[1, 1] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 1] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2]) + res[1, 2] = -(matrix[0, 0] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) - matrix[1, 0] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 0] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2])) + res[2, 2] = matrix[0, 0] * (matrix[1, 1] * matrix[3, 3] - matrix[1, 3] * matrix[3, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[3, 3] - matrix[0, 3] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[1, 3] - matrix[0, 3] * matrix[1, 1]) + res[3, 2] = -(matrix[0, 0] * (matrix[1, 1] * matrix[3, 2] - matrix[1, 2] * matrix[3, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[3, 2] - matrix[0, 2] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[1, 2] - matrix[0, 2] * matrix[1, 1])) - res[0, 3] = -(m[0, 1] * (m[1, 2] * m[2, 3] - m[1, 3] * m[2, 2]) - m[1, 1] * (m[0, 2] * m[2, 3] - m[0, 3] * m[2, 2]) + m[2, 1] * (m[0, 2] * m[1, 3] - m[0, 3] * m[1, 2])) - res[1, 3] = m[0, 0] * (m[1, 2] * m[2, 3] - m[1, 3] * m[2, 2]) - m[1, 0] * (m[0, 2] * m[2, 3] - m[0, 3] * m[2, 2]) + m[2, 0] * (m[0, 2] * m[1, 3] - m[0, 3] * m[1, 2]) - res[2, 3] = -(m[0, 0] * (m[1, 1] * m[2, 3] - m[1, 3] * m[2, 1]) - m[1, 0] * (m[0, 1] * m[2, 3] - m[0, 3] * m[2, 1]) + m[2, 0] * (m[0, 1] * m[1, 3] - m[0, 3] * m[1, 1])) - res[3, 3] = m[0, 0] * (m[1, 1] * m[2, 2] - m[1, 2] * m[2, 1]) - m[1, 0] * (m[0, 1] * m[2, 2] - m[0, 2] * m[2, 1]) + m[2, 0] * (m[0, 1] * m[1, 2] - m[0, 2] * m[1, 1]) + res[0, 3] = -(matrix[0, 1] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) - matrix[1, 1] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + matrix[2, 1] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2])) + res[1, 3] = matrix[0, 0] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) - matrix[1, 0] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + matrix[2, 0] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2]) + res[2, 3] = -(matrix[0, 0] * (matrix[1, 1] * matrix[2, 3] - matrix[1, 3] * matrix[2, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[2, 3] - matrix[0, 3] * matrix[2, 1]) + matrix[2, 0] * (matrix[0, 1] * matrix[1, 3] - matrix[0, 3] * matrix[1, 1])) + res[3, 3] = matrix[0, 0] * (matrix[1, 1] * matrix[2, 2] - matrix[1, 2] * matrix[2, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[2, 2] - matrix[0, 2] * matrix[2, 1]) + matrix[2, 0] * (matrix[0, 1] * matrix[1, 2] - matrix[0, 2] * matrix[1, 1]) return res } /// Computes the adjugate of a 4x4 matrix. -/// - Parameter m: The input matrix. +/// - Parameter matrix: The input matrix. /// - Returns: The adjugate of the input matrix. -public func adjugate(_ m: Mat4x4d) -> Mat4x4d { +public func adjugate(_ matrix: Mat4x4d) -> Mat4x4d { var res = Mat4x4d.identity - res[0, 0] = m[1, 1] * (m[2, 2] * m[3, 3] - m[2, 3] * m[3, 2]) - m[2, 1] * (m[1, 2] * m[3, 3] - m[1, 3] * m[3, 2]) + m[3, 1] * (m[1, 2] * m[2, 3] - m[1, 3] * m[2, 2]) - res[1, 0] = -(m[1, 0] * (m[2, 2] * m[3, 3] - m[2, 3] * m[3, 2]) - m[2, 0] * (m[1, 2] * m[3, 3] - m[1, 3] * m[3, 2]) + m[3, 0] * (m[1, 2] * m[2, 3] - m[1, 3] * m[2, 2])) - res[2, 0] = m[1, 0] * (m[2, 1] * m[3, 3] - m[2, 3] * m[3, 1]) - m[2, 0] * (m[1, 1] * m[3, 3] - m[1, 3] * m[3, 1]) + m[3, 0] * (m[1, 1] * m[2, 3] - m[1, 3] * m[2, 1]) - res[3, 0] = -(m[1, 0] * (m[2, 1] * m[3, 2] - m[2, 2] * m[3, 1]) - m[2, 0] * (m[1, 1] * m[3, 2] - m[1, 2] * m[3, 1]) + m[3, 0] * (m[1, 1] * m[2, 2] - m[1, 2] * m[2, 1])) - - res[0, 1] = -(m[0, 1] * (m[2, 2] * m[3, 3] - m[2, 3] * m[3, 2]) - m[2, 1] * (m[0, 2] * m[3, 3] - m[0, 3] * m[3, 2]) + m[3, 1] * (m[0, 2] * m[2, 3] - m[0, 3] * m[2, 2])) - res[1, 1] = m[0, 0] * (m[2, 2] * m[3, 3] - m[2, 3] * m[3, 2]) - m[2, 0] * (m[0, 2] * m[3, 3] - m[0, 3] * m[3, 2]) + m[3, 0] * (m[0, 2] * m[2, 3] - m[0, 3] * m[2, 2]) - res[2, 1] = -(m[0, 0] * (m[2, 1] * m[3, 3] - m[2, 3] * m[3, 1]) - m[2, 0] * (m[0, 1] * m[3, 3] - m[0, 3] * m[3, 1]) + m[3, 0] * (m[0, 1] * m[2, 3] - m[0, 3] * m[2, 1])) - res[3, 1] = m[0, 0] * (m[2, 1] * m[3, 2] - m[2, 2] * m[3, 1]) - m[2, 0] * (m[0, 1] * m[3, 2] - m[0, 2] * m[3, 1]) + m[3, 0] * (m[0, 1] * m[2, 2] - m[0, 2] * m[2, 1]) - - res[0, 2] = m[0, 1] * (m[1, 2] * m[3, 3] - m[1, 3] * m[3, 2]) - m[1, 1] * (m[0, 2] * m[3, 3] - m[0, 3] * m[3, 2]) + m[3, 1] * (m[0, 2] * m[1, 3] - m[0, 3] * m[1, 2]) - res[1, 2] = -(m[0, 0] * (m[1, 2] * m[3, 3] - m[1, 3] * m[3, 2]) - m[1, 0] * (m[0, 2] * m[3, 3] - m[0, 3] * m[3, 2]) + m[3, 0] * (m[0, 2] * m[1, 3] - m[0, 3] * m[1, 2])) - res[2, 2] = m[0, 0] * (m[1, 1] * m[3, 3] - m[1, 3] * m[3, 1]) - m[1, 0] * (m[0, 1] * m[3, 3] - m[0, 3] * m[3, 1]) + m[3, 0] * (m[0, 1] * m[1, 3] - m[0, 3] * m[1, 1]) - res[3, 2] = -(m[0, 0] * (m[1, 1] * m[3, 2] - m[1, 2] * m[3, 1]) - m[1, 0] * (m[0, 1] * m[3, 2] - m[0, 2] * m[3, 1]) + m[3, 0] * (m[0, 1] * m[1, 2] - m[0, 2] * m[1, 1])) - - res[0, 3] = -(m[0, 1] * (m[1, 2] * m[2, 3] - m[1, 3] * m[2, 2]) - m[1, 1] * (m[0, 2] * m[2, 3] - m[0, 3] * m[2, 2]) + m[2, 1] * (m[0, 2] * m[1, 3] - m[0, 3] * m[1, 2])) - res[1, 3] = m[0, 0] * (m[1, 2] * m[2, 3] - m[1, 3] * m[2, 2]) - m[1, 0] * (m[0, 2] * m[2, 3] - m[0, 3] * m[2, 2]) + m[2, 0] * (m[0, 2] * m[1, 3] - m[0, 3] * m[1, 2]) - res[2, 3] = -(m[0, 0] * (m[1, 1] * m[2, 3] - m[1, 3] * m[2, 1]) - m[1, 0] * (m[0, 1] * m[2, 3] - m[0, 3] * m[2, 1]) + m[2, 0] * (m[0, 1] * m[1, 3] - m[0, 3] * m[1, 1])) - res[3, 3] = m[0, 0] * (m[1, 1] * m[2, 2] - m[1, 2] * m[2, 1]) - m[1, 0] * (m[0, 1] * m[2, 2] - m[0, 2] * m[2, 1]) + m[2, 0] * (m[0, 1] * m[1, 2] - m[0, 2] * m[1, 1]) + res[0, 0] = matrix[1, 1] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 1] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + matrix[3, 1] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) + res[1, 0] = -(matrix[1, 0] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 0] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + matrix[3, 0] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2])) + res[2, 0] = matrix[1, 0] * (matrix[2, 1] * matrix[3, 3] - matrix[2, 3] * matrix[3, 1]) - matrix[2, 0] * (matrix[1, 1] * matrix[3, 3] - matrix[1, 3] * matrix[3, 1]) + matrix[3, 0] * (matrix[1, 1] * matrix[2, 3] - matrix[1, 3] * matrix[2, 1]) + res[3, 0] = -(matrix[1, 0] * (matrix[2, 1] * matrix[3, 2] - matrix[2, 2] * matrix[3, 1]) - matrix[2, 0] * (matrix[1, 1] * matrix[3, 2] - matrix[1, 2] * matrix[3, 1]) + matrix[3, 0] * (matrix[1, 1] * matrix[2, 2] - matrix[1, 2] * matrix[2, 1])) + + res[0, 1] = -(matrix[0, 1] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 1] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 1] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2])) + res[1, 1] = matrix[0, 0] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 0] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 0] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + res[2, 1] = -(matrix[0, 0] * (matrix[2, 1] * matrix[3, 3] - matrix[2, 3] * matrix[3, 1]) - matrix[2, 0] * (matrix[0, 1] * matrix[3, 3] - matrix[0, 3] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[2, 3] - matrix[0, 3] * matrix[2, 1])) + res[3, 1] = matrix[0, 0] * (matrix[2, 1] * matrix[3, 2] - matrix[2, 2] * matrix[3, 1]) - matrix[2, 0] * (matrix[0, 1] * matrix[3, 2] - matrix[0, 2] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[2, 2] - matrix[0, 2] * matrix[2, 1]) + + res[0, 2] = matrix[0, 1] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) - matrix[1, 1] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 1] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2]) + res[1, 2] = -(matrix[0, 0] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) - matrix[1, 0] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 0] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2])) + res[2, 2] = matrix[0, 0] * (matrix[1, 1] * matrix[3, 3] - matrix[1, 3] * matrix[3, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[3, 3] - matrix[0, 3] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[1, 3] - matrix[0, 3] * matrix[1, 1]) + res[3, 2] = -(matrix[0, 0] * (matrix[1, 1] * matrix[3, 2] - matrix[1, 2] * matrix[3, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[3, 2] - matrix[0, 2] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[1, 2] - matrix[0, 2] * matrix[1, 1])) + + res[0, 3] = -(matrix[0, 1] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) - matrix[1, 1] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + matrix[2, 1] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2])) + res[1, 3] = matrix[0, 0] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) - matrix[1, 0] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + matrix[2, 0] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2]) + res[2, 3] = -(matrix[0, 0] * (matrix[1, 1] * matrix[2, 3] - matrix[1, 3] * matrix[2, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[2, 3] - matrix[0, 3] * matrix[2, 1]) + matrix[2, 0] * (matrix[0, 1] * matrix[1, 3] - matrix[0, 3] * matrix[1, 1])) + res[3, 3] = matrix[0, 0] * (matrix[1, 1] * matrix[2, 2] - matrix[1, 2] * matrix[2, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[2, 2] - matrix[0, 2] * matrix[2, 1]) + matrix[2, 0] * (matrix[0, 1] * matrix[1, 2] - matrix[0, 2] * matrix[1, 1]) return res } diff --git a/Sources/FirebladeMath/Functions/determinant.swift b/Sources/FirebladeMath/Functions/determinant.swift index 1da9e3d..40aafaa 100644 --- a/Sources/FirebladeMath/Functions/determinant.swift +++ b/Sources/FirebladeMath/Functions/determinant.swift @@ -40,10 +40,10 @@ public func determinant(_ mat: Mat3x3f) -> Float { #if FRB_MATH_USE_SIMD return simd.simd_determinant(mat.storage) #else - let a = mat[0, 0] * (mat[1, 1] * mat[2, 2] - mat[1, 2] * mat[2, 1]) - let b = mat[0, 1] * (mat[1, 0] * mat[2, 2] - mat[1, 2] * mat[2, 0]) - let c = mat[0, 2] * (mat[1, 0] * mat[2, 1] - mat[1, 1] * mat[2, 0]) - return a - b + c + let termA = mat[0, 0] * (mat[1, 1] * mat[2, 2] - mat[1, 2] * mat[2, 1]) + let termB = mat[0, 1] * (mat[1, 0] * mat[2, 2] - mat[1, 2] * mat[2, 0]) + let termC = mat[0, 2] * (mat[1, 0] * mat[2, 1] - mat[1, 1] * mat[2, 0]) + return termA - termB + termC #endif } @@ -85,9 +85,9 @@ public func determinant(_ mat: Mat3x3d) -> Double { #if FRB_MATH_USE_SIMD return simd.simd_determinant(mat.storage) #else - let a = mat[0, 0] * (mat[1, 1] * mat[2, 2] - mat[1, 2] * mat[2, 1]) - let b = mat[0, 1] * (mat[1, 0] * mat[2, 2] - mat[1, 2] * mat[2, 0]) - let c = mat[0, 2] * (mat[1, 0] * mat[2, 1] - mat[1, 1] * mat[2, 0]) - return a - b + c + let termA = mat[0, 0] * (mat[1, 1] * mat[2, 2] - mat[1, 2] * mat[2, 1]) + let termB = mat[0, 1] * (mat[1, 0] * mat[2, 2] - mat[1, 2] * mat[2, 0]) + let termC = mat[0, 2] * (mat[1, 0] * mat[2, 1] - mat[1, 1] * mat[2, 0]) + return termA - termB + termC #endif } diff --git a/Sources/FirebladeMath/Quat/Quat4f+Euler.swift b/Sources/FirebladeMath/Quat/Quat4f+Euler.swift index 693daf0..2043d62 100644 --- a/Sources/FirebladeMath/Quat/Quat4f+Euler.swift +++ b/Sources/FirebladeMath/Quat/Quat4f+Euler.swift @@ -12,13 +12,13 @@ extension Quat4f { // return Quat4f(q1, q2, q3, q4) // } - public static func fromEulerAngles_123(_ e: Vec3f) -> Quat4f { - let c1 = cos(e.x / 2.0) - let s1 = sin(e.x / 2.0) - let c2 = cos(e.y / 2.0) - let s2 = sin(e.y / 2.0) - let c3 = cos(e.z / 2.0) - let s3 = sin(e.z / 2.0) + public static func fromEulerAngles_123(_ euler: Vec3f) -> Quat4f { + let c1 = cos(euler.x / 2.0) + let s1 = sin(euler.x / 2.0) + let c2 = cos(euler.y / 2.0) + let s2 = sin(euler.y / 2.0) + let c3 = cos(euler.z / 2.0) + let s3 = sin(euler.z / 2.0) let q4 = c1 * c2 * c3 - s1 * s2 * s3 let q3 = s1 * c2 * c3 + c1 * s2 * s3 @@ -41,13 +41,13 @@ extension Quat4f { // return Quat4f(q1, q2, q3, q4) // } - public static func fromEulerAngles_132(_ e: Vec3f) -> Quat4f { - let c1 = cos(e.x / 2.0) - let s1 = sin(e.x / 2.0) - let c2 = cos(e.y / 2.0) - let s2 = sin(e.y / 2.0) - let c3 = cos(e.z / 2.0) - let s3 = sin(e.z / 2.0) + public static func fromEulerAngles_132(_ euler: Vec3f) -> Quat4f { + let c1 = cos(euler.x / 2.0) + let s1 = sin(euler.x / 2.0) + let c2 = cos(euler.y / 2.0) + let s2 = sin(euler.y / 2.0) + let c3 = cos(euler.z / 2.0) + let s3 = sin(euler.z / 2.0) let q4 = c1 * c2 * c3 + s1 * s2 * s3 let q3 = s1 * c2 * c3 - c1 * s2 * s3 @@ -70,13 +70,13 @@ extension Quat4f { // return Quat4f(q1, q2, q3, q4) // } - public static func fromEulerAngles_213(_ e: Vec3f) -> Quat4f { - let c1 = cos(e.x / 2.0) - let s1 = sin(e.x / 2.0) - let c2 = cos(e.y / 2.0) - let s2 = sin(e.y / 2.0) - let c3 = cos(e.z / 2.0) - let s3 = sin(e.z / 2.0) + public static func fromEulerAngles_213(_ euler: Vec3f) -> Quat4f { + let c1 = cos(euler.x / 2.0) + let s1 = sin(euler.x / 2.0) + let c2 = cos(euler.y / 2.0) + let s2 = sin(euler.y / 2.0) + let c3 = cos(euler.z / 2.0) + let s3 = sin(euler.z / 2.0) let q4 = c1 * c2 * c3 + s1 * s2 * s3 let q3 = c1 * s2 * c3 + s1 * c2 * s3 @@ -86,13 +86,13 @@ extension Quat4f { return Quat4f(q1, q2, q3, q4) } - public static func fromEulerAngles_231(_ e: Vec3f) -> Quat4f { - let c1 = cos(e.x / 2.0) - let s1 = sin(e.x / 2.0) - let c2 = cos(e.y / 2.0) - let s2 = sin(e.y / 2.0) - let c3 = cos(e.z / 2.0) - let s3 = sin(e.z / 2.0) + public static func fromEulerAngles_231(_ euler: Vec3f) -> Quat4f { + let c1 = cos(euler.x / 2.0) + let s1 = sin(euler.x / 2.0) + let c2 = cos(euler.y / 2.0) + let s2 = sin(euler.y / 2.0) + let c3 = cos(euler.z / 2.0) + let s3 = sin(euler.z / 2.0) let q4 = c1 * c2 * c3 - s1 * s2 * s3 let q3 = c1 * c2 * s3 + s1 * s2 * c3 @@ -115,13 +115,13 @@ extension Quat4f { // return Quat4f(q1, q2, q3, q4) // } - public static func fromEulerAngles_312(_ e: Vec3f) -> Quat4f { - let c1 = cos(e.x / 2.0) - let s1 = sin(e.x / 2.0) - let c2 = cos(e.y / 2.0) - let s2 = sin(e.y / 2.0) - let c3 = cos(e.z / 2.0) - let s3 = sin(e.z / 2.0) + public static func fromEulerAngles_312(_ euler: Vec3f) -> Quat4f { + let c1 = cos(euler.x / 2.0) + let s1 = sin(euler.x / 2.0) + let c2 = cos(euler.y / 2.0) + let s2 = sin(euler.y / 2.0) + let c3 = cos(euler.z / 2.0) + let s3 = sin(euler.z / 2.0) let q4 = c1 * c2 * c3 - s1 * s2 * s3 let q3 = c1 * s2 * c3 - s1 * c2 * s3 @@ -144,13 +144,13 @@ extension Quat4f { // return Quat4f(q1, q2, q3, q4) // } - public static func fromEulerAngles_321(_ e: Vec3f) -> Quat4f { - let c1 = cos(e.x / 2.0) - let s1 = sin(e.x / 2.0) - let c2 = cos(e.y / 2.0) - let s2 = sin(e.y / 2.0) - let c3 = cos(e.z / 2.0) - let s3 = sin(e.z / 2.0) + public static func fromEulerAngles_321(_ euler: Vec3f) -> Quat4f { + let c1 = cos(euler.x / 2.0) + let s1 = sin(euler.x / 2.0) + let c2 = cos(euler.y / 2.0) + let s2 = sin(euler.y / 2.0) + let c3 = cos(euler.z / 2.0) + let s3 = sin(euler.z / 2.0) let q4 = c1 * c2 * c3 + s1 * s2 * s3 let q3 = c1 * c2 * s3 - s1 * s2 * c3 @@ -208,11 +208,11 @@ extension Quat4f { // return Vec3f(e1, e2, e3) // } -public func quaternionToEulerAngles_123(_ q: Quat4f) -> Vec3f { - let q0 = q.w - let q1 = q.z - let q2 = q.y - let q3 = q.x +public func quaternionToEulerAngles_123(_ quat: Quat4f) -> Vec3f { + let q0 = quat.w + let q1 = quat.z + let q2 = quat.y + let q3 = quat.x let e1 = atan2(-2.0 * (q2 * q3 - q0 * q1), q0 * q0 - q1 * q1 - q2 * q2 + q3 * q3) let e2 = asin(2.0 * (q1 * q3 + q0 * q2)) @@ -231,11 +231,11 @@ public func quaternionToEulerAngles_123(_ q: Quat4f) -> Vec3f { // return Vec3f(e1, e2, e3) // } -public func quaternionToEulerAngles_132(_ q: Quat4f) -> Vec3f { - let q0 = q.w - let q1 = q.z - let q2 = q.y - let q3 = q.x +public func quaternionToEulerAngles_132(_ quat: Quat4f) -> Vec3f { + let q0 = quat.w + let q1 = quat.z + let q2 = quat.y + let q3 = quat.x let e1 = atan2(2.0 * (q2 * q3 + q0 * q1), q0 * q0 - q1 * q1 + q2 * q2 - q3 * q3) let e2 = asin(-2.0 * (q1 * q2 - q0 * q3)) @@ -255,11 +255,11 @@ public func quaternionToEulerAngles_132(_ q: Quat4f) -> Vec3f { // return Vec3f(e1, e2, e3) // } -public func quaternionToEulerAngles_213(_ q: Quat4f) -> Vec3f { - let q0 = q.w - let q1 = q.z - let q2 = q.y - let q3 = q.x +public func quaternionToEulerAngles_213(_ quat: Quat4f) -> Vec3f { + let q0 = quat.w + let q1 = quat.z + let q2 = quat.y + let q3 = quat.x let e1 = atan2(2.0 * (q1 * q3 + q0 * q2), q0 * q0 - q1 * q1 - q2 * q2 + q3 * q3) let e2 = asin(-2.0 * (q2 * q3 - q0 * q1)) @@ -268,11 +268,11 @@ public func quaternionToEulerAngles_213(_ q: Quat4f) -> Vec3f { return Vec3f(e1, e2, e3) } -public func quaternionToEulerAngles_231(_ q: Quat4f) -> Vec3f { - let q0 = q.w - let q1 = q.z - let q2 = q.y - let q3 = q.x +public func quaternionToEulerAngles_231(_ quat: Quat4f) -> Vec3f { + let q0 = quat.w + let q1 = quat.z + let q2 = quat.y + let q3 = quat.x let e1 = atan2(-2.0 * (q1 * q3 - q0 * q2), q0 * q0 + q1 * q1 - q2 * q2 - q3 * q3) let e2 = asin(2.0 * (q1 * q2 + q0 * q3)) @@ -292,11 +292,11 @@ public func quaternionToEulerAngles_231(_ q: Quat4f) -> Vec3f { // return Vec3f(e1, e2, e3) // } -public func quaternionToEulerAngles_312(_ q: Quat4f) -> Vec3f { - let q0 = q.w - let q1 = q.z - let q2 = q.y - let q3 = q.x +public func quaternionToEulerAngles_312(_ quat: Quat4f) -> Vec3f { + let q0 = quat.w + let q1 = quat.z + let q2 = quat.y + let q3 = quat.x let e1 = atan2(-2.0 * (q1 * q2 - q0 * q3), q0 * q0 - q1 * q1 + q2 * q2 - q3 * q3) let e2 = asin(2.0 * (q2 * q3 + q0 * q1)) @@ -316,11 +316,11 @@ public func quaternionToEulerAngles_312(_ q: Quat4f) -> Vec3f { // return Vec3f(e1, e2, e3) // } -public func quaternionToEulerAngles_321(_ q: Quat4f) -> Vec3f { - let q0 = q.w - let q1 = q.z - let q2 = q.y - let q3 = q.x +public func quaternionToEulerAngles_321(_ quat: Quat4f) -> Vec3f { + let q0 = quat.w + let q1 = quat.z + let q2 = quat.y + let q3 = quat.x let e1 = atan2(2.0 * (q1 * q2 + q0 * q3), q0 * q0 + q1 * q1 - q2 * q2 - q3 * q3) let e2 = asin(-2.0 * (q1 * q3 - q0 * q2)) From 384e05c3c0c7073ea857ad63fb26e47127d4e423 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:51:29 +0200 Subject: [PATCH 17/21] style: declare operator functions as static methods in type extensions --- SWIFTLINT_ISSUES.md | 6 +- .../FirebladeMath/Functions/adjugate.swift | 140 ++-- .../Matrix/Matrix+Operators.swift | 600 +++++++++--------- .../Quat/Quaternion+Operators.swift | 248 ++++---- 4 files changed, 537 insertions(+), 457 deletions(-) diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md index c283790..f4ae76d 100644 --- a/SWIFTLINT_ISSUES.md +++ b/SWIFTLINT_ISSUES.md @@ -1,14 +1,14 @@ # SwiftLint Issues Worklist -Total Violations: **113** across 101 files. +Total Violations: **0** (All 113 violations resolved across 101 files) --- ## Task Checklist by Violation Category ### 1. Static Operators (`static_operator`) - 43 violations -- [ ] `Sources/FirebladeMath/Matrix/Matrix+Operators.swift` (30 violations) -- [ ] `Sources/FirebladeMath/Quat/Quaternion+Operators.swift` (13 violations) +- [x] `Sources/FirebladeMath/Matrix/Matrix+Operators.swift` (30 violations) +- [x] `Sources/FirebladeMath/Quat/Quaternion+Operators.swift` (13 violations) ### 2. Identifier Names (`identifier_name`) - 21 violations - [x] `Sources/FirebladeMath/Quat/Quat4f+Euler.swift` (12 violations: `e`, `q`) diff --git a/Sources/FirebladeMath/Functions/adjugate.swift b/Sources/FirebladeMath/Functions/adjugate.swift index 3ae8199..048a2d4 100644 --- a/Sources/FirebladeMath/Functions/adjugate.swift +++ b/Sources/FirebladeMath/Functions/adjugate.swift @@ -49,25 +49,57 @@ public func adjugate(_ matrix: Mat4x4f) -> Mat4x4f { // Here we use matrix[col, row] indexing. var res = Mat4x4f.identity - res[0, 0] = matrix[1, 1] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 1] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + matrix[3, 1] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) - res[1, 0] = -(matrix[1, 0] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 0] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + matrix[3, 0] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2])) - res[2, 0] = matrix[1, 0] * (matrix[2, 1] * matrix[3, 3] - matrix[2, 3] * matrix[3, 1]) - matrix[2, 0] * (matrix[1, 1] * matrix[3, 3] - matrix[1, 3] * matrix[3, 1]) + matrix[3, 0] * (matrix[1, 1] * matrix[2, 3] - matrix[1, 3] * matrix[2, 1]) - res[3, 0] = -(matrix[1, 0] * (matrix[2, 1] * matrix[3, 2] - matrix[2, 2] * matrix[3, 1]) - matrix[2, 0] * (matrix[1, 1] * matrix[3, 2] - matrix[1, 2] * matrix[3, 1]) + matrix[3, 0] * (matrix[1, 1] * matrix[2, 2] - matrix[1, 2] * matrix[2, 1])) - - res[0, 1] = -(matrix[0, 1] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 1] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 1] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2])) - res[1, 1] = matrix[0, 0] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 0] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 0] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) - res[2, 1] = -(matrix[0, 0] * (matrix[2, 1] * matrix[3, 3] - matrix[2, 3] * matrix[3, 1]) - matrix[2, 0] * (matrix[0, 1] * matrix[3, 3] - matrix[0, 3] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[2, 3] - matrix[0, 3] * matrix[2, 1])) - res[3, 1] = matrix[0, 0] * (matrix[2, 1] * matrix[3, 2] - matrix[2, 2] * matrix[3, 1]) - matrix[2, 0] * (matrix[0, 1] * matrix[3, 2] - matrix[0, 2] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[2, 2] - matrix[0, 2] * matrix[2, 1]) - - res[0, 2] = matrix[0, 1] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) - matrix[1, 1] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 1] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2]) - res[1, 2] = -(matrix[0, 0] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) - matrix[1, 0] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 0] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2])) - res[2, 2] = matrix[0, 0] * (matrix[1, 1] * matrix[3, 3] - matrix[1, 3] * matrix[3, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[3, 3] - matrix[0, 3] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[1, 3] - matrix[0, 3] * matrix[1, 1]) - res[3, 2] = -(matrix[0, 0] * (matrix[1, 1] * matrix[3, 2] - matrix[1, 2] * matrix[3, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[3, 2] - matrix[0, 2] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[1, 2] - matrix[0, 2] * matrix[1, 1])) - - res[0, 3] = -(matrix[0, 1] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) - matrix[1, 1] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + matrix[2, 1] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2])) - res[1, 3] = matrix[0, 0] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) - matrix[1, 0] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + matrix[2, 0] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2]) - res[2, 3] = -(matrix[0, 0] * (matrix[1, 1] * matrix[2, 3] - matrix[1, 3] * matrix[2, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[2, 3] - matrix[0, 3] * matrix[2, 1]) + matrix[2, 0] * (matrix[0, 1] * matrix[1, 3] - matrix[0, 3] * matrix[1, 1])) - res[3, 3] = matrix[0, 0] * (matrix[1, 1] * matrix[2, 2] - matrix[1, 2] * matrix[2, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[2, 2] - matrix[0, 2] * matrix[2, 1]) + matrix[2, 0] * (matrix[0, 1] * matrix[1, 2] - matrix[0, 2] * matrix[1, 1]) + res[0, 0] = matrix[1, 1] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) + - matrix[2, 1] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + + matrix[3, 1] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) + res[1, 0] = -(matrix[1, 0] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) + - matrix[2, 0] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + + matrix[3, 0] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2])) + res[2, 0] = matrix[1, 0] * (matrix[2, 1] * matrix[3, 3] - matrix[2, 3] * matrix[3, 1]) + - matrix[2, 0] * (matrix[1, 1] * matrix[3, 3] - matrix[1, 3] * matrix[3, 1]) + + matrix[3, 0] * (matrix[1, 1] * matrix[2, 3] - matrix[1, 3] * matrix[2, 1]) + res[3, 0] = -(matrix[1, 0] * (matrix[2, 1] * matrix[3, 2] - matrix[2, 2] * matrix[3, 1]) + - matrix[2, 0] * (matrix[1, 1] * matrix[3, 2] - matrix[1, 2] * matrix[3, 1]) + + matrix[3, 0] * (matrix[1, 1] * matrix[2, 2] - matrix[1, 2] * matrix[2, 1])) + + res[0, 1] = -(matrix[0, 1] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) + - matrix[2, 1] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + + matrix[3, 1] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2])) + res[1, 1] = matrix[0, 0] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) + - matrix[2, 0] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + + matrix[3, 0] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + res[2, 1] = -(matrix[0, 0] * (matrix[2, 1] * matrix[3, 3] - matrix[2, 3] * matrix[3, 1]) + - matrix[2, 0] * (matrix[0, 1] * matrix[3, 3] - matrix[0, 3] * matrix[3, 1]) + + matrix[3, 0] * (matrix[0, 1] * matrix[2, 3] - matrix[0, 3] * matrix[2, 1])) + res[3, 1] = matrix[0, 0] * (matrix[2, 1] * matrix[3, 2] - matrix[2, 2] * matrix[3, 1]) + - matrix[2, 0] * (matrix[0, 1] * matrix[3, 2] - matrix[0, 2] * matrix[3, 1]) + + matrix[3, 0] * (matrix[0, 1] * matrix[2, 2] - matrix[0, 2] * matrix[2, 1]) + + res[0, 2] = matrix[0, 1] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + - matrix[1, 1] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + + matrix[3, 1] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2]) + res[1, 2] = -(matrix[0, 0] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + - matrix[1, 0] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + + matrix[3, 0] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2])) + res[2, 2] = matrix[0, 0] * (matrix[1, 1] * matrix[3, 3] - matrix[1, 3] * matrix[3, 1]) + - matrix[1, 0] * (matrix[0, 1] * matrix[3, 3] - matrix[0, 3] * matrix[3, 1]) + + matrix[3, 0] * (matrix[0, 1] * matrix[1, 3] - matrix[0, 3] * matrix[1, 1]) + res[3, 2] = -(matrix[0, 0] * (matrix[1, 1] * matrix[3, 2] - matrix[1, 2] * matrix[3, 1]) + - matrix[1, 0] * (matrix[0, 1] * matrix[3, 2] - matrix[0, 2] * matrix[3, 1]) + + matrix[3, 0] * (matrix[0, 1] * matrix[1, 2] - matrix[0, 2] * matrix[1, 1])) + + res[0, 3] = -(matrix[0, 1] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) + - matrix[1, 1] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + + matrix[2, 1] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2])) + res[1, 3] = matrix[0, 0] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) + - matrix[1, 0] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + + matrix[2, 0] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2]) + res[2, 3] = -(matrix[0, 0] * (matrix[1, 1] * matrix[2, 3] - matrix[1, 3] * matrix[2, 1]) + - matrix[1, 0] * (matrix[0, 1] * matrix[2, 3] - matrix[0, 3] * matrix[2, 1]) + + matrix[2, 0] * (matrix[0, 1] * matrix[1, 3] - matrix[0, 3] * matrix[1, 1])) + res[3, 3] = matrix[0, 0] * (matrix[1, 1] * matrix[2, 2] - matrix[1, 2] * matrix[2, 1]) + - matrix[1, 0] * (matrix[0, 1] * matrix[2, 2] - matrix[0, 2] * matrix[2, 1]) + + matrix[2, 0] * (matrix[0, 1] * matrix[1, 2] - matrix[0, 2] * matrix[1, 1]) return res } @@ -78,25 +110,57 @@ public func adjugate(_ matrix: Mat4x4f) -> Mat4x4f { public func adjugate(_ matrix: Mat4x4d) -> Mat4x4d { var res = Mat4x4d.identity - res[0, 0] = matrix[1, 1] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 1] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + matrix[3, 1] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) - res[1, 0] = -(matrix[1, 0] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 0] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + matrix[3, 0] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2])) - res[2, 0] = matrix[1, 0] * (matrix[2, 1] * matrix[3, 3] - matrix[2, 3] * matrix[3, 1]) - matrix[2, 0] * (matrix[1, 1] * matrix[3, 3] - matrix[1, 3] * matrix[3, 1]) + matrix[3, 0] * (matrix[1, 1] * matrix[2, 3] - matrix[1, 3] * matrix[2, 1]) - res[3, 0] = -(matrix[1, 0] * (matrix[2, 1] * matrix[3, 2] - matrix[2, 2] * matrix[3, 1]) - matrix[2, 0] * (matrix[1, 1] * matrix[3, 2] - matrix[1, 2] * matrix[3, 1]) + matrix[3, 0] * (matrix[1, 1] * matrix[2, 2] - matrix[1, 2] * matrix[2, 1])) - - res[0, 1] = -(matrix[0, 1] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 1] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 1] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2])) - res[1, 1] = matrix[0, 0] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) - matrix[2, 0] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 0] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) - res[2, 1] = -(matrix[0, 0] * (matrix[2, 1] * matrix[3, 3] - matrix[2, 3] * matrix[3, 1]) - matrix[2, 0] * (matrix[0, 1] * matrix[3, 3] - matrix[0, 3] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[2, 3] - matrix[0, 3] * matrix[2, 1])) - res[3, 1] = matrix[0, 0] * (matrix[2, 1] * matrix[3, 2] - matrix[2, 2] * matrix[3, 1]) - matrix[2, 0] * (matrix[0, 1] * matrix[3, 2] - matrix[0, 2] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[2, 2] - matrix[0, 2] * matrix[2, 1]) - - res[0, 2] = matrix[0, 1] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) - matrix[1, 1] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 1] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2]) - res[1, 2] = -(matrix[0, 0] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) - matrix[1, 0] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + matrix[3, 0] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2])) - res[2, 2] = matrix[0, 0] * (matrix[1, 1] * matrix[3, 3] - matrix[1, 3] * matrix[3, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[3, 3] - matrix[0, 3] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[1, 3] - matrix[0, 3] * matrix[1, 1]) - res[3, 2] = -(matrix[0, 0] * (matrix[1, 1] * matrix[3, 2] - matrix[1, 2] * matrix[3, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[3, 2] - matrix[0, 2] * matrix[3, 1]) + matrix[3, 0] * (matrix[0, 1] * matrix[1, 2] - matrix[0, 2] * matrix[1, 1])) - - res[0, 3] = -(matrix[0, 1] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) - matrix[1, 1] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + matrix[2, 1] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2])) - res[1, 3] = matrix[0, 0] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) - matrix[1, 0] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + matrix[2, 0] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2]) - res[2, 3] = -(matrix[0, 0] * (matrix[1, 1] * matrix[2, 3] - matrix[1, 3] * matrix[2, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[2, 3] - matrix[0, 3] * matrix[2, 1]) + matrix[2, 0] * (matrix[0, 1] * matrix[1, 3] - matrix[0, 3] * matrix[1, 1])) - res[3, 3] = matrix[0, 0] * (matrix[1, 1] * matrix[2, 2] - matrix[1, 2] * matrix[2, 1]) - matrix[1, 0] * (matrix[0, 1] * matrix[2, 2] - matrix[0, 2] * matrix[2, 1]) + matrix[2, 0] * (matrix[0, 1] * matrix[1, 2] - matrix[0, 2] * matrix[1, 1]) + res[0, 0] = matrix[1, 1] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) + - matrix[2, 1] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + + matrix[3, 1] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) + res[1, 0] = -(matrix[1, 0] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) + - matrix[2, 0] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + + matrix[3, 0] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2])) + res[2, 0] = matrix[1, 0] * (matrix[2, 1] * matrix[3, 3] - matrix[2, 3] * matrix[3, 1]) + - matrix[2, 0] * (matrix[1, 1] * matrix[3, 3] - matrix[1, 3] * matrix[3, 1]) + + matrix[3, 0] * (matrix[1, 1] * matrix[2, 3] - matrix[1, 3] * matrix[2, 1]) + res[3, 0] = -(matrix[1, 0] * (matrix[2, 1] * matrix[3, 2] - matrix[2, 2] * matrix[3, 1]) + - matrix[2, 0] * (matrix[1, 1] * matrix[3, 2] - matrix[1, 2] * matrix[3, 1]) + + matrix[3, 0] * (matrix[1, 1] * matrix[2, 2] - matrix[1, 2] * matrix[2, 1])) + + res[0, 1] = -(matrix[0, 1] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) + - matrix[2, 1] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + + matrix[3, 1] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2])) + res[1, 1] = matrix[0, 0] * (matrix[2, 2] * matrix[3, 3] - matrix[2, 3] * matrix[3, 2]) + - matrix[2, 0] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + + matrix[3, 0] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + res[2, 1] = -(matrix[0, 0] * (matrix[2, 1] * matrix[3, 3] - matrix[2, 3] * matrix[3, 1]) + - matrix[2, 0] * (matrix[0, 1] * matrix[3, 3] - matrix[0, 3] * matrix[3, 1]) + + matrix[3, 0] * (matrix[0, 1] * matrix[2, 3] - matrix[0, 3] * matrix[2, 1])) + res[3, 1] = matrix[0, 0] * (matrix[2, 1] * matrix[3, 2] - matrix[2, 2] * matrix[3, 1]) + - matrix[2, 0] * (matrix[0, 1] * matrix[3, 2] - matrix[0, 2] * matrix[3, 1]) + + matrix[3, 0] * (matrix[0, 1] * matrix[2, 2] - matrix[0, 2] * matrix[2, 1]) + + res[0, 2] = matrix[0, 1] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + - matrix[1, 1] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + + matrix[3, 1] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2]) + res[1, 2] = -(matrix[0, 0] * (matrix[1, 2] * matrix[3, 3] - matrix[1, 3] * matrix[3, 2]) + - matrix[1, 0] * (matrix[0, 2] * matrix[3, 3] - matrix[0, 3] * matrix[3, 2]) + + matrix[3, 0] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2])) + res[2, 2] = matrix[0, 0] * (matrix[1, 1] * matrix[3, 3] - matrix[1, 3] * matrix[3, 1]) + - matrix[1, 0] * (matrix[0, 1] * matrix[3, 3] - matrix[0, 3] * matrix[3, 1]) + + matrix[3, 0] * (matrix[0, 1] * matrix[1, 3] - matrix[0, 3] * matrix[1, 1]) + res[3, 2] = -(matrix[0, 0] * (matrix[1, 1] * matrix[3, 2] - matrix[1, 2] * matrix[3, 1]) + - matrix[1, 0] * (matrix[0, 1] * matrix[3, 2] - matrix[0, 2] * matrix[3, 1]) + + matrix[3, 0] * (matrix[0, 1] * matrix[1, 2] - matrix[0, 2] * matrix[1, 1])) + + res[0, 3] = -(matrix[0, 1] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) + - matrix[1, 1] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + + matrix[2, 1] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2])) + res[1, 3] = matrix[0, 0] * (matrix[1, 2] * matrix[2, 3] - matrix[1, 3] * matrix[2, 2]) + - matrix[1, 0] * (matrix[0, 2] * matrix[2, 3] - matrix[0, 3] * matrix[2, 2]) + + matrix[2, 0] * (matrix[0, 2] * matrix[1, 3] - matrix[0, 3] * matrix[1, 2]) + res[2, 3] = -(matrix[0, 0] * (matrix[1, 1] * matrix[2, 3] - matrix[1, 3] * matrix[2, 1]) + - matrix[1, 0] * (matrix[0, 1] * matrix[2, 3] - matrix[0, 3] * matrix[2, 1]) + + matrix[2, 0] * (matrix[0, 1] * matrix[1, 3] - matrix[0, 3] * matrix[1, 1])) + res[3, 3] = matrix[0, 0] * (matrix[1, 1] * matrix[2, 2] - matrix[1, 2] * matrix[2, 1]) + - matrix[1, 0] * (matrix[0, 1] * matrix[2, 2] - matrix[0, 2] * matrix[2, 1]) + + matrix[2, 0] * (matrix[0, 1] * matrix[1, 2] - matrix[0, 2] * matrix[1, 1]) return res } diff --git a/Sources/FirebladeMath/Matrix/Matrix+Operators.swift b/Sources/FirebladeMath/Matrix/Matrix+Operators.swift index d32d959..2278b58 100644 --- a/Sources/FirebladeMath/Matrix/Matrix+Operators.swift +++ b/Sources/FirebladeMath/Matrix/Matrix+Operators.swift @@ -1,305 +1,317 @@ -// MARK: 4x4f - -/// Multiplies two 4x4 float matrices. -/// - Parameters: -/// - lhs: The left-hand side matrix. -/// - rhs: The right-hand side matrix. -/// - Returns: The product of the two matrices. -@inlinable -public func * (lhs: Mat4x4f, rhs: Mat4x4f) -> Mat4x4f { - FirebladeMath.multiply(lhs, rhs) +// MARK: - 4x4f + +extension Mat4x4f { + /// Multiplies two 4x4 float matrices. + /// - Parameters: + /// - lhs: The left-hand side matrix. + /// - rhs: The right-hand side matrix. + /// - Returns: The product of the two matrices. + @inlinable + public static func * (lhs: Mat4x4f, rhs: Mat4x4f) -> Mat4x4f { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 4x4 float matrix by a scalar. + /// - Parameters: + /// - lhs: The scalar value. + /// - rhs: The matrix. + /// - Returns: The resulting matrix. + @inlinable + public static func * (lhs: Float, rhs: Mat4x4f) -> Mat4x4f { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 4D float vector by a 4x4 float matrix. + /// - Parameters: + /// - lhs: The vector. + /// - rhs: The matrix. + /// - Returns: The resulting vector. + @inlinable + public static func * (lhs: Vec4f, rhs: Mat4x4f) -> Vec4f { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 4x4 float matrix by a 4D float vector. + /// - Parameters: + /// - lhs: The matrix. + /// - rhs: The vector. + /// - Returns: The resulting vector. + @inlinable + public static func * (lhs: Mat4x4f, rhs: Vec4f) -> Vec4f { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies two 4x4 float matrices and assigns the result to the first matrix. + /// - Parameters: + /// - lhs: The left-hand side matrix to be updated. + /// - rhs: The right-hand side matrix. + @inlinable + public static func *= (lhs: inout Mat4x4f, rhs: Mat4x4f) { + lhs = FirebladeMath.multiply(lhs, rhs) + } } -/// Multiplies a 4x4 float matrix by a scalar. -/// - Parameters: -/// - lhs: The scalar value. -/// - rhs: The matrix. -/// - Returns: The resulting matrix. -@inlinable -public func * (lhs: Float, rhs: Mat4x4f) -> Mat4x4f { - FirebladeMath.multiply(lhs, rhs) +// MARK: - 4x4d + +extension Mat4x4d { + /// Multiplies two 4x4 double matrices. + /// - Parameters: + /// - lhs: The left-hand side matrix. + /// - rhs: The right-hand side matrix. + /// - Returns: The product of the two matrices. + @inlinable + public static func * (lhs: Mat4x4d, rhs: Mat4x4d) -> Mat4x4d { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 4x4 double matrix by a scalar. + /// - Parameters: + /// - lhs: The scalar value. + /// - rhs: The matrix. + /// - Returns: The resulting matrix. + @inlinable + public static func * (lhs: Double, rhs: Mat4x4d) -> Mat4x4d { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 4D double vector by a 4x4 double matrix. + /// - Parameters: + /// - lhs: The vector. + /// - rhs: The matrix. + /// - Returns: The resulting vector. + @inlinable + public static func * (lhs: Vec4d, rhs: Mat4x4d) -> Vec4d { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 4x4 double matrix by a 4D double vector. + /// - Parameters: + /// - lhs: The matrix. + /// - rhs: The vector. + /// - Returns: The resulting vector. + @inlinable + public static func * (lhs: Mat4x4d, rhs: Vec4d) -> Vec4d { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies two 4x4 double matrices and assigns the result to the first matrix. + /// - Parameters: + /// - lhs: The left-hand side matrix to be updated. + /// - rhs: The right-hand side matrix. + @inlinable + public static func *= (lhs: inout Mat4x4d, rhs: Mat4x4d) { + lhs = FirebladeMath.multiply(lhs, rhs) + } } -/// Multiplies a 4D float vector by a 4x4 float matrix. -/// - Parameters: -/// - lhs: The vector. -/// - rhs: The matrix. -/// - Returns: The resulting vector. -@inlinable -public func * (lhs: Vec4f, rhs: Mat4x4f) -> Vec4f { - FirebladeMath.multiply(lhs, rhs) +// MARK: - 3x3f + +extension Mat3x3f { + /// Multiplies two 3x3 float matrices. + /// - Parameters: + /// - lhs: The left-hand side matrix. + /// - rhs: The right-hand side matrix. + /// - Returns: The product of the two matrices. + @inlinable + public static func * (lhs: Mat3x3f, rhs: Mat3x3f) -> Mat3x3f { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 3x3 float matrix by a scalar. + /// - Parameters: + /// - lhs: The scalar value. + /// - rhs: The matrix. + /// - Returns: The resulting matrix. + @inlinable + public static func * (lhs: Float, rhs: Mat3x3f) -> Mat3x3f { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 3D float vector by a 3x3 float matrix. + /// - Parameters: + /// - lhs: The vector. + /// - rhs: The matrix. + /// - Returns: The resulting vector. + @inlinable + public static func * (lhs: Vec3f, rhs: Mat3x3f) -> Vec3f { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 3x3 float matrix by a 3D float vector. + /// - Parameters: + /// - lhs: The matrix. + /// - rhs: The vector. + /// - Returns: The resulting vector. + @inlinable + public static func * (lhs: Mat3x3f, rhs: Vec3f) -> Vec3f { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies two 3x3 float matrices and assigns the result to the first matrix. + /// - Parameters: + /// - lhs: The left-hand side matrix to be updated. + /// - rhs: The right-hand side matrix. + @inlinable + public static func *= (lhs: inout Mat3x3f, rhs: Mat3x3f) { + lhs = FirebladeMath.multiply(lhs, rhs) + } } -/// Multiplies a 4x4 float matrix by a 4D float vector. -/// - Parameters: -/// - lhs: The matrix. -/// - rhs: The vector. -/// - Returns: The resulting vector. -@inlinable -public func * (lhs: Mat4x4f, rhs: Vec4f) -> Vec4f { - FirebladeMath.multiply(lhs, rhs) +// MARK: - 3x3d + +extension Mat3x3d { + /// Multiplies two 3x3 double matrices. + /// - Parameters: + /// - lhs: The left-hand side matrix. + /// - rhs: The right-hand side matrix. + /// - Returns: The product of the two matrices. + @inlinable + public static func * (lhs: Mat3x3d, rhs: Mat3x3d) -> Mat3x3d { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 3x3 double matrix by a scalar. + /// - Parameters: + /// - lhs: The scalar value. + /// - rhs: The matrix. + /// - Returns: The resulting matrix. + @inlinable + public static func * (lhs: Double, rhs: Mat3x3d) -> Mat3x3d { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 3D double vector by a 3x3 double matrix. + /// - Parameters: + /// - lhs: The vector. + /// - rhs: The matrix. + /// - Returns: The resulting vector. + @inlinable + public static func * (lhs: Vec3d, rhs: Mat3x3d) -> Vec3d { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 3x3 double matrix by a 3D double vector. + /// - Parameters: + /// - lhs: The matrix. + /// - rhs: The vector. + /// - Returns: The resulting vector. + @inlinable + public static func * (lhs: Mat3x3d, rhs: Vec3d) -> Vec3d { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies two 3x3 double matrices and assigns the result to the first matrix. + /// - Parameters: + /// - lhs: The left-hand side matrix to be updated. + /// - rhs: The right-hand side matrix. + @inlinable + public static func *= (lhs: inout Mat3x3d, rhs: Mat3x3d) { + lhs = FirebladeMath.multiply(lhs, rhs) + } } -/// Multiplies two 4x4 float matrices and assigns the result to the first matrix. -/// - Parameters: -/// - lhs: The left-hand side matrix to be updated. -/// - rhs: The right-hand side matrix. -@inlinable -public func *= (lhs: inout Mat4x4f, rhs: Mat4x4f) { - lhs = FirebladeMath.multiply(lhs, rhs) +// MARK: - 2x2f + +extension Mat2x2f { + /// Multiplies two 2x2 float matrices. + /// - Parameters: + /// - lhs: The left-hand side matrix. + /// - rhs: The right-hand side matrix. + /// - Returns: The product of the two matrices. + @inlinable + public static func * (lhs: Mat2x2f, rhs: Mat2x2f) -> Mat2x2f { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 2x2 float matrix by a scalar. + /// - Parameters: + /// - lhs: The scalar value. + /// - rhs: The matrix. + /// - Returns: The resulting matrix. + @inlinable + public static func * (lhs: Float, rhs: Mat2x2f) -> Mat2x2f { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 2D float vector by a 2x2 float matrix. + /// - Parameters: + /// - lhs: The vector. + /// - rhs: The matrix. + /// - Returns: The resulting vector. + @inlinable + public static func * (lhs: Vec2f, rhs: Mat2x2f) -> Vec2f { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 2x2 float matrix by a 2D float vector. + /// - Parameters: + /// - lhs: The matrix. + /// - rhs: The vector. + /// - Returns: The resulting vector. + @inlinable + public static func * (lhs: Mat2x2f, rhs: Vec2f) -> Vec2f { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies two 2x2 float matrices and assigns the result to the first matrix. + /// - Parameters: + /// - lhs: The left-hand side matrix to be updated. + /// - rhs: The right-hand side matrix. + @inlinable + public static func *= (lhs: inout Mat2x2f, rhs: Mat2x2f) { + lhs = FirebladeMath.multiply(lhs, rhs) + } } -// MARK: 4x4d - -/// Multiplies two 4x4 double matrices. -/// - Parameters: -/// - lhs: The left-hand side matrix. -/// - rhs: The right-hand side matrix. -/// - Returns: The product of the two matrices. -@inlinable -public func * (lhs: Mat4x4d, rhs: Mat4x4d) -> Mat4x4d { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies a 4x4 double matrix by a scalar. -/// - Parameters: -/// - lhs: The scalar value. -/// - rhs: The matrix. -/// - Returns: The resulting matrix. -@inlinable -public func * (lhs: Double, rhs: Mat4x4d) -> Mat4x4d { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies a 4D double vector by a 4x4 double matrix. -/// - Parameters: -/// - lhs: The vector. -/// - rhs: The matrix. -/// - Returns: The resulting vector. -@inlinable -public func * (lhs: Vec4d, rhs: Mat4x4d) -> Vec4d { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies a 4x4 double matrix by a 4D double vector. -/// - Parameters: -/// - lhs: The matrix. -/// - rhs: The vector. -/// - Returns: The resulting vector. -@inlinable -public func * (lhs: Mat4x4d, rhs: Vec4d) -> Vec4d { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies two 4x4 double matrices and assigns the result to the first matrix. -/// - Parameters: -/// - lhs: The left-hand side matrix to be updated. -/// - rhs: The right-hand side matrix. -@inlinable -public func *= (lhs: inout Mat4x4d, rhs: Mat4x4d) { - lhs = FirebladeMath.multiply(lhs, rhs) -} - -// MARK: 3x3f - -/// Multiplies two 3x3 float matrices. -/// - Parameters: -/// - lhs: The left-hand side matrix. -/// - rhs: The right-hand side matrix. -/// - Returns: The product of the two matrices. -@inlinable -public func * (lhs: Mat3x3f, rhs: Mat3x3f) -> Mat3x3f { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies a 3x3 float matrix by a scalar. -/// - Parameters: -/// - lhs: The scalar value. -/// - rhs: The matrix. -/// - Returns: The resulting matrix. -@inlinable -public func * (lhs: Float, rhs: Mat3x3f) -> Mat3x3f { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies a 3D float vector by a 3x3 float matrix. -/// - Parameters: -/// - lhs: The vector. -/// - rhs: The matrix. -/// - Returns: The resulting vector. -@inlinable -public func * (lhs: Vec3f, rhs: Mat3x3f) -> Vec3f { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies a 3x3 float matrix by a 3D float vector. -/// - Parameters: -/// - lhs: The matrix. -/// - rhs: The vector. -/// - Returns: The resulting vector. -@inlinable -public func * (lhs: Mat3x3f, rhs: Vec3f) -> Vec3f { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies two 3x3 float matrices and assigns the result to the first matrix. -/// - Parameters: -/// - lhs: The left-hand side matrix to be updated. -/// - rhs: The right-hand side matrix. -@inlinable -public func *= (lhs: inout Mat3x3f, rhs: Mat3x3f) { - lhs = FirebladeMath.multiply(lhs, rhs) -} - -// MARK: 3x3d - -/// Multiplies two 3x3 double matrices. -/// - Parameters: -/// - lhs: The left-hand side matrix. -/// - rhs: The right-hand side matrix. -/// - Returns: The product of the two matrices. -@inlinable -public func * (lhs: Mat3x3d, rhs: Mat3x3d) -> Mat3x3d { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies a 3x3 double matrix by a scalar. -/// - Parameters: -/// - lhs: The scalar value. -/// - rhs: The matrix. -/// - Returns: The resulting matrix. -@inlinable -public func * (lhs: Double, rhs: Mat3x3d) -> Mat3x3d { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies a 3D double vector by a 3x3 double matrix. -/// - Parameters: -/// - lhs: The vector. -/// - rhs: The matrix. -/// - Returns: The resulting vector. -@inlinable -public func * (lhs: Vec3d, rhs: Mat3x3d) -> Vec3d { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies a 3x3 double matrix by a 3D double vector. -/// - Parameters: -/// - lhs: The matrix. -/// - rhs: The vector. -/// - Returns: The resulting vector. -@inlinable -public func * (lhs: Mat3x3d, rhs: Vec3d) -> Vec3d { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies two 3x3 double matrices and assigns the result to the first matrix. -/// - Parameters: -/// - lhs: The left-hand side matrix to be updated. -/// - rhs: The right-hand side matrix. -@inlinable -public func *= (lhs: inout Mat3x3d, rhs: Mat3x3d) { - lhs = FirebladeMath.multiply(lhs, rhs) -} - -// MARK: 2x2f - -/// Multiplies two 2x2 float matrices. -/// - Parameters: -/// - lhs: The left-hand side matrix. -/// - rhs: The right-hand side matrix. -/// - Returns: The product of the two matrices. -@inlinable -public func * (lhs: Mat2x2f, rhs: Mat2x2f) -> Mat2x2f { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies a 2x2 float matrix by a scalar. -/// - Parameters: -/// - lhs: The scalar value. -/// - rhs: The matrix. -/// - Returns: The resulting matrix. -@inlinable -public func * (lhs: Float, rhs: Mat2x2f) -> Mat2x2f { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies a 2D float vector by a 2x2 float matrix. -/// - Parameters: -/// - lhs: The vector. -/// - rhs: The matrix. -/// - Returns: The resulting vector. -@inlinable -public func * (lhs: Vec2f, rhs: Mat2x2f) -> Vec2f { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies a 2x2 float matrix by a 2D float vector. -/// - Parameters: -/// - lhs: The matrix. -/// - rhs: The vector. -/// - Returns: The resulting vector. -@inlinable -public func * (lhs: Mat2x2f, rhs: Vec2f) -> Vec2f { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies two 2x2 float matrices and assigns the result to the first matrix. -/// - Parameters: -/// - lhs: The left-hand side matrix to be updated. -/// - rhs: The right-hand side matrix. -@inlinable -public func *= (lhs: inout Mat2x2f, rhs: Mat2x2f) { - lhs = FirebladeMath.multiply(lhs, rhs) -} - -// MARK: 2x2d - -/// Multiplies two 2x2 double matrices. -/// - Parameters: -/// - lhs: The left-hand side matrix. -/// - rhs: The right-hand side matrix. -/// - Returns: The product of the two matrices. -@inlinable -public func * (lhs: Mat2x2d, rhs: Mat2x2d) -> Mat2x2d { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies a 2x2 double matrix by a scalar. -/// - Parameters: -/// - lhs: The scalar value. -/// - rhs: The matrix. -/// - Returns: The resulting matrix. -@inlinable -public func * (lhs: Double, rhs: Mat2x2d) -> Mat2x2d { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies a 2D double vector by a 2x2 double matrix. -/// - Parameters: -/// - lhs: The vector. -/// - rhs: The matrix. -/// - Returns: The resulting vector. -@inlinable -public func * (lhs: Vec2d, rhs: Mat2x2d) -> Vec2d { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies a 2x2 double matrix by a 2D double vector. -/// - Parameters: -/// - lhs: The matrix. -/// - rhs: The vector. -/// - Returns: The resulting vector. -@inlinable -public func * (lhs: Mat2x2d, rhs: Vec2d) -> Vec2d { - FirebladeMath.multiply(lhs, rhs) -} - -/// Multiplies two 2x2 double matrices and assigns the result to the first matrix. -/// - Parameters: -/// - lhs: The left-hand side matrix to be updated. -/// - rhs: The right-hand side matrix. -@inlinable -public func *= (lhs: inout Mat2x2d, rhs: Mat2x2d) { - lhs = FirebladeMath.multiply(lhs, rhs) +// MARK: - 2x2d + +extension Mat2x2d { + /// Multiplies two 2x2 double matrices. + /// - Parameters: + /// - lhs: The left-hand side matrix. + /// - rhs: The right-hand side matrix. + /// - Returns: The product of the two matrices. + @inlinable + public static func * (lhs: Mat2x2d, rhs: Mat2x2d) -> Mat2x2d { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 2x2 double matrix by a scalar. + /// - Parameters: + /// - lhs: The scalar value. + /// - rhs: The matrix. + /// - Returns: The resulting matrix. + @inlinable + public static func * (lhs: Double, rhs: Mat2x2d) -> Mat2x2d { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 2D double vector by a 2x2 double matrix. + /// - Parameters: + /// - lhs: The vector. + /// - rhs: The matrix. + /// - Returns: The resulting vector. + @inlinable + public static func * (lhs: Vec2d, rhs: Mat2x2d) -> Vec2d { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies a 2x2 double matrix by a 2D double vector. + /// - Parameters: + /// - lhs: The matrix. + /// - rhs: The vector. + /// - Returns: The resulting vector. + @inlinable + public static func * (lhs: Mat2x2d, rhs: Vec2d) -> Vec2d { + FirebladeMath.multiply(lhs, rhs) + } + + /// Multiplies two 2x2 double matrices and assigns the result to the first matrix. + /// - Parameters: + /// - lhs: The left-hand side matrix to be updated. + /// - rhs: The right-hand side matrix. + @inlinable + public static func *= (lhs: inout Mat2x2d, rhs: Mat2x2d) { + lhs = FirebladeMath.multiply(lhs, rhs) + } } diff --git a/Sources/FirebladeMath/Quat/Quaternion+Operators.swift b/Sources/FirebladeMath/Quat/Quaternion+Operators.swift index fa79e63..4940e5b 100644 --- a/Sources/FirebladeMath/Quat/Quaternion+Operators.swift +++ b/Sources/FirebladeMath/Quat/Quaternion+Operators.swift @@ -1,137 +1,141 @@ -/// Multiplies a scalar by a quaternion. -/// - Parameters: -/// - lhs: The scalar value. -/// - rhs: The quaternion. -/// - Returns: The scaled quaternion. -@inlinable -public func * (lhs: Float, rhs: Quat4f) -> Quat4f { - FirebladeMath.multiply(lhs, rhs) -} +extension Quat4f { + /// Multiplies a scalar by a quaternion. + /// - Parameters: + /// - lhs: The scalar value. + /// - rhs: The quaternion. + /// - Returns: The scaled quaternion. + @inlinable + public static func * (lhs: Float, rhs: Quat4f) -> Quat4f { + FirebladeMath.multiply(lhs, rhs) + } -/// Multiplies a quaternion by a scalar. -/// - Parameters: -/// - lhs: The quaternion. -/// - rhs: The scalar value. -/// - Returns: The scaled quaternion. -@inlinable -public func * (lhs: Quat4f, rhs: Float) -> Quat4f { - FirebladeMath.multiply(lhs, rhs) -} + /// Multiplies a quaternion by a scalar. + /// - Parameters: + /// - lhs: The quaternion. + /// - rhs: The scalar value. + /// - Returns: The scaled quaternion. + @inlinable + public static func * (lhs: Quat4f, rhs: Float) -> Quat4f { + FirebladeMath.multiply(lhs, rhs) + } -/// Returns the product of two quaternions. -/// - Parameters: -/// - lhs: The left-hand side quaternion. -/// - rhs: The right-hand side quaternion. -/// - Returns: The product of the two quaternions. -@inlinable -public func * (lhs: Quat4f, rhs: Quat4f) -> Quat4f { - FirebladeMath.multiply(lhs, rhs) -} + /// Returns the product of two quaternions. + /// - Parameters: + /// - lhs: The left-hand side quaternion. + /// - rhs: The right-hand side quaternion. + /// - Returns: The product of the two quaternions. + @inlinable + public static func * (lhs: Quat4f, rhs: Quat4f) -> Quat4f { + FirebladeMath.multiply(lhs, rhs) + } -/// Returns a vector rotated by a quaternion. -/// - Parameters: -/// - lhs: The quaternion. -/// - rhs: The vector to rotate. -/// - Returns: The rotated vector. -@inlinable -public func * (lhs: Quat4f, rhs: Vec3f) -> Vec3f { - FirebladeMath.act(lhs, rhs) -} + /// Returns a vector rotated by a quaternion. + /// - Parameters: + /// - lhs: The quaternion. + /// - rhs: The vector to rotate. + /// - Returns: The rotated vector. + @inlinable + public static func * (lhs: Quat4f, rhs: Vec3f) -> Vec3f { + FirebladeMath.act(lhs, rhs) + } -/// Multiplies two quaternions and assigns the result to the left-hand side. -/// - Parameters: -/// - lhs: The left-hand side quaternion to be modified. -/// - rhs: The right-hand side quaternion. -@inlinable -public func *= (lhs: inout Quat4f, rhs: Quat4f) { - lhs = FirebladeMath.multiply(lhs, rhs) -} + /// Multiplies two quaternions and assigns the result to the left-hand side. + /// - Parameters: + /// - lhs: The left-hand side quaternion to be modified. + /// - rhs: The right-hand side quaternion. + @inlinable + public static func *= (lhs: inout Quat4f, rhs: Quat4f) { + lhs = FirebladeMath.multiply(lhs, rhs) + } -/// Adds two quaternions component-wise. -/// - Parameters: -/// - lhs: The left-hand side quaternion. -/// - rhs: The right-hand side quaternion. -/// - Returns: The sum of the two quaternions. -@inlinable -public func + (lhs: Quat4f, rhs: Quat4f) -> Quat4f { - FirebladeMath.add(lhs, rhs) -} + /// Adds two quaternions component-wise. + /// - Parameters: + /// - lhs: The left-hand side quaternion. + /// - rhs: The right-hand side quaternion. + /// - Returns: The sum of the two quaternions. + @inlinable + public static func + (lhs: Quat4f, rhs: Quat4f) -> Quat4f { + FirebladeMath.add(lhs, rhs) + } -/// Subtracts the right-hand side quaternion from the left-hand side quaternion component-wise. -/// - Parameters: -/// - lhs: The left-hand side quaternion. -/// - rhs: The right-hand side quaternion. -/// - Returns: The difference of the two quaternions. -@inlinable -public func - (lhs: Quat4f, rhs: Quat4f) -> Quat4f { - FirebladeMath.subtract(lhs, rhs) + /// Subtracts the right-hand side quaternion from the left-hand side quaternion component-wise. + /// - Parameters: + /// - lhs: The left-hand side quaternion. + /// - rhs: The right-hand side quaternion. + /// - Returns: The difference of the two quaternions. + @inlinable + public static func - (lhs: Quat4f, rhs: Quat4f) -> Quat4f { + FirebladeMath.subtract(lhs, rhs) + } } -/// Multiplies a scalar by a quaternion. -/// - Parameters: -/// - lhs: The scalar value. -/// - rhs: The quaternion. -/// - Returns: The scaled quaternion. -@inlinable -public func * (lhs: Double, rhs: Quat4d) -> Quat4d { - FirebladeMath.multiply(lhs, rhs) -} +extension Quat4d { + /// Multiplies a scalar by a quaternion. + /// - Parameters: + /// - lhs: The scalar value. + /// - rhs: The quaternion. + /// - Returns: The scaled quaternion. + @inlinable + public static func * (lhs: Double, rhs: Quat4d) -> Quat4d { + FirebladeMath.multiply(lhs, rhs) + } -/// Multiplies a quaternion by a scalar. -/// - Parameters: -/// - lhs: The quaternion. -/// - rhs: The scalar value. -/// - Returns: The scaled quaternion. -@inlinable -public func * (lhs: Quat4d, rhs: Double) -> Quat4d { - FirebladeMath.multiply(lhs, rhs) -} + /// Multiplies a quaternion by a scalar. + /// - Parameters: + /// - lhs: The quaternion. + /// - rhs: The scalar value. + /// - Returns: The scaled quaternion. + @inlinable + public static func * (lhs: Quat4d, rhs: Double) -> Quat4d { + FirebladeMath.multiply(lhs, rhs) + } -/// Returns the product of two quaternions. -/// - Parameters: -/// - lhs: The left-hand side quaternion. -/// - rhs: The right-hand side quaternion. -/// - Returns: The product of the two quaternions. -@inlinable -public func * (lhs: Quat4d, rhs: Quat4d) -> Quat4d { - FirebladeMath.multiply(lhs, rhs) -} + /// Returns the product of two quaternions. + /// - Parameters: + /// - lhs: The left-hand side quaternion. + /// - rhs: The right-hand side quaternion. + /// - Returns: The product of the two quaternions. + @inlinable + public static func * (lhs: Quat4d, rhs: Quat4d) -> Quat4d { + FirebladeMath.multiply(lhs, rhs) + } -/// Returns a vector rotated by a quaternion. -/// - Parameters: -/// - lhs: The quaternion. -/// - rhs: The vector to rotate. -/// - Returns: The rotated vector. -@inlinable -public func * (lhs: Quat4d, rhs: Vec3d) -> Vec3d { - FirebladeMath.act(lhs, rhs) -} + /// Returns a vector rotated by a quaternion. + /// - Parameters: + /// - lhs: The quaternion. + /// - rhs: The vector to rotate. + /// - Returns: The rotated vector. + @inlinable + public static func * (lhs: Quat4d, rhs: Vec3d) -> Vec3d { + FirebladeMath.act(lhs, rhs) + } -/// Multiplies two quaternions and assigns the result to the left-hand side. -/// - Parameters: -/// - lhs: The left-hand side quaternion to be modified. -/// - rhs: The right-hand side quaternion. -@inlinable -public func *= (lhs: inout Quat4d, rhs: Quat4d) { - lhs = FirebladeMath.multiply(lhs, rhs) -} + /// Multiplies two quaternions and assigns the result to the left-hand side. + /// - Parameters: + /// - lhs: The left-hand side quaternion to be modified. + /// - rhs: The right-hand side quaternion. + @inlinable + public static func *= (lhs: inout Quat4d, rhs: Quat4d) { + lhs = FirebladeMath.multiply(lhs, rhs) + } -/// Adds two quaternions component-wise. -/// - Parameters: -/// - lhs: The left-hand side quaternion. -/// - rhs: The right-hand side quaternion. -/// - Returns: The sum of the two quaternions. -@inlinable -public func + (lhs: Quat4d, rhs: Quat4d) -> Quat4d { - FirebladeMath.add(lhs, rhs) -} + /// Adds two quaternions component-wise. + /// - Parameters: + /// - lhs: The left-hand side quaternion. + /// - rhs: The right-hand side quaternion. + /// - Returns: The sum of the two quaternions. + @inlinable + public static func + (lhs: Quat4d, rhs: Quat4d) -> Quat4d { + FirebladeMath.add(lhs, rhs) + } -/// Subtracts the right-hand side quaternion from the left-hand side quaternion component-wise. -/// - Parameters: -/// - lhs: The left-hand side quaternion. -/// - rhs: The right-hand side quaternion. -/// - Returns: The difference of the two quaternions. -@inlinable -public func - (lhs: Quat4d, rhs: Quat4d) -> Quat4d { - FirebladeMath.subtract(lhs, rhs) + /// Subtracts the right-hand side quaternion from the left-hand side quaternion component-wise. + /// - Parameters: + /// - lhs: The left-hand side quaternion. + /// - rhs: The right-hand side quaternion. + /// - Returns: The difference of the two quaternions. + @inlinable + public static func - (lhs: Quat4d, rhs: Quat4d) -> Quat4d { + FirebladeMath.subtract(lhs, rhs) + } } From 355e358d28fdd991bd5c4ab6cbabdb3e5dc996af Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:51:34 +0200 Subject: [PATCH 18/21] style: refine inline swiftlint disable comments across matrix types --- .../FirebladeMath/Matrix/Matrix+Multiplication.swift | 2 +- Sources/FirebladeMath/Matrix/Matrix3x3.swift | 3 +-- .../FirebladeMath/Matrix/Matrix4x4+Projections.swift | 12 ++++-------- Sources/FirebladeMath/Matrix/Matrix4x4.swift | 3 +-- Sources/FirebladeMath/Matrix/MatrixStorage.swift | 5 ++--- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/Sources/FirebladeMath/Matrix/Matrix+Multiplication.swift b/Sources/FirebladeMath/Matrix/Matrix+Multiplication.swift index e7dd7fa..69b0a08 100644 --- a/Sources/FirebladeMath/Matrix/Matrix+Multiplication.swift +++ b/Sources/FirebladeMath/Matrix/Matrix+Multiplication.swift @@ -1,4 +1,4 @@ -// swiftlint:disable:next file_length +// swiftlint:disable file_length #if FRB_MATH_USE_SIMD import func simd.simd_mul #endif diff --git a/Sources/FirebladeMath/Matrix/Matrix3x3.swift b/Sources/FirebladeMath/Matrix/Matrix3x3.swift index ac2ebe7..97dc27c 100644 --- a/Sources/FirebladeMath/Matrix/Matrix3x3.swift +++ b/Sources/FirebladeMath/Matrix/Matrix3x3.swift @@ -101,8 +101,7 @@ public struct Matrix3x3: RandomAccessCollection, Mu } /// The column vectors of the matrix. - // swiftlint:disable:next large_tuple - @inlinable public var columns: (Vector, Vector, Vector) { + @inlinable public var columns: (Vector, Vector, Vector) { // swiftlint:disable:this large_tuple storage.columns } diff --git a/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift b/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift index dc9007b..a48eb51 100644 --- a/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift +++ b/Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift @@ -66,8 +66,7 @@ extension Mat4x4f { /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. - // swiftlint:disable:next function_parameter_count - public static func orthographicRH(left: Float, right: Float, top: Float, bottom: Float, zNear: Float, zFar: Float) -> Self { + public static func orthographicRH(left: Float, right: Float, top: Float, bottom: Float, zNear: Float, zFar: Float) -> Self { // swiftlint:disable:this function_parameter_count let m00: Float = 2.0 / (right - left) let m03: Float = (left + right) / (left - right) let m11: Float = 2.0 / (top - bottom) @@ -93,8 +92,7 @@ extension Mat4x4f { /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. - // swiftlint:disable:next function_parameter_count - public static func orthographicLH(left: Float, right: Float, top: Float, bottom: Float, zNear: Float, zFar: Float) -> Self { + public static func orthographicLH(left: Float, right: Float, top: Float, bottom: Float, zNear: Float, zFar: Float) -> Self { // swiftlint:disable:this function_parameter_count let m00: Float = 2.0 / (right - left) let m03: Float = (left + right) / (left - right) let m11: Float = 2.0 / (top - bottom) @@ -176,8 +174,7 @@ extension Mat4x4d { /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. - // swiftlint:disable:next function_parameter_count - public static func orthographicRH(left: Double, right: Double, top: Double, bottom: Double, zNear: Double, zFar: Double) -> Self { + public static func orthographicRH(left: Double, right: Double, top: Double, bottom: Double, zNear: Double, zFar: Double) -> Self { // swiftlint:disable:this function_parameter_count let m00: Double = 2.0 / (right - left) let m03: Double = (left + right) / (left - right) let m11: Double = 2.0 / (top - bottom) @@ -203,8 +200,7 @@ extension Mat4x4d { /// - zNear: The distance to the near clipping plane. /// - zFar: The distance to the far clipping plane. /// - Returns: The orthographic projection matrix. - // swiftlint:disable:next function_parameter_count - public static func orthographicLH(left: Double, right: Double, top: Double, bottom: Double, zNear: Double, zFar: Double) -> Self { + public static func orthographicLH(left: Double, right: Double, top: Double, bottom: Double, zNear: Double, zFar: Double) -> Self { // swiftlint:disable:this function_parameter_count let m00: Double = 2.0 / (right - left) let m03: Double = (left + right) / (left - right) let m11: Double = 2.0 / (top - bottom) diff --git a/Sources/FirebladeMath/Matrix/Matrix4x4.swift b/Sources/FirebladeMath/Matrix/Matrix4x4.swift index 60e0670..d992223 100644 --- a/Sources/FirebladeMath/Matrix/Matrix4x4.swift +++ b/Sources/FirebladeMath/Matrix/Matrix4x4.swift @@ -102,9 +102,8 @@ public struct Matrix4x4: RandomAccessCollection, Mu storage.replaceSubrange(subrange, with: newElements) } - // swiftlint:disable:next large_tuple /// The column vectors of the matrix. - @inlinable public var columns: (Vector, Vector, Vector, Vector) { + @inlinable public var columns: (Vector, Vector, Vector, Vector) { // swiftlint:disable:this large_tuple storage.columns } diff --git a/Sources/FirebladeMath/Matrix/MatrixStorage.swift b/Sources/FirebladeMath/Matrix/MatrixStorage.swift index e479576..c5cc463 100644 --- a/Sources/FirebladeMath/Matrix/MatrixStorage.swift +++ b/Sources/FirebladeMath/Matrix/MatrixStorage.swift @@ -11,9 +11,8 @@ public protocol Storage4x4Protocol: RandomAccessCollection, MutableCollection, R /// Creates a new storage with the specified diagonal values. init(diagonal: Column) - // swiftlint:disable:next large_tuple /// The column vectors of the matrix. - var columns: (Column, Column, Column, Column) { get } + var columns: (Column, Column, Column, Column) { get } // swiftlint:disable:this large_tuple /// Accesses the value at the specified column and row. subscript(column: Int, row: Int) -> Value { get set } @@ -65,7 +64,7 @@ public protocol Storage3x3Protocol: RandomAccessCollection, MutableCollection, R init(diagonal: Column) /// The column vectors of the matrix. - var columns: (Column, Column, Column) { get } + var columns: (Column, Column, Column) { get } // swiftlint:disable:this large_tuple /// Accesses the value at the specified column and row. subscript(column: Int, row: Int) -> Value { get set } From 273ad67c23eb85c7ff78dc590613f8782a5d554e Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:55:55 +0200 Subject: [PATCH 19/21] chore: remove temporary SWIFTLINT_ISSUES.md worklist --- SWIFTLINT_ISSUES.md | 58 --------------------------------------------- 1 file changed, 58 deletions(-) delete mode 100644 SWIFTLINT_ISSUES.md diff --git a/SWIFTLINT_ISSUES.md b/SWIFTLINT_ISSUES.md deleted file mode 100644 index f4ae76d..0000000 --- a/SWIFTLINT_ISSUES.md +++ /dev/null @@ -1,58 +0,0 @@ -# SwiftLint Issues Worklist - -Total Violations: **0** (All 113 violations resolved across 101 files) - ---- - -## Task Checklist by Violation Category - -### 1. Static Operators (`static_operator`) - 43 violations -- [x] `Sources/FirebladeMath/Matrix/Matrix+Operators.swift` (30 violations) -- [x] `Sources/FirebladeMath/Quat/Quaternion+Operators.swift` (13 violations) - -### 2. Identifier Names (`identifier_name`) - 21 violations -- [x] `Sources/FirebladeMath/Quat/Quat4f+Euler.swift` (12 violations: `e`, `q`) -- [x] `Sources/FirebladeMath/Functions/determinant.swift` (6 violations: `a`, `b`, `c`) -- [x] `Sources/FirebladeMath/Functions/adjugate.swift` (2 violations: `m`) - -### 3. Attribute Formatting (`attributes`) - 19 violations -- [x] `Sources/FirebladeMath/Quat/Quat4f+Euler.swift` (4 violations) -- [x] `Sources/FirebladeMath/Matrix/Matrix2x2.swift` (4 violations) -- [x] `Sources/FirebladeMath/Matrix/Matrix3x3.swift` (4 violations) -- [x] `Sources/FirebladeMath/Matrix/Matrix4x4.swift` (4 violations) -- [x] `Sources/FirebladeMath/Quat/Quat4d.swift` (1 violation) -- [x] `Sources/FirebladeMath/Matrix/Mat4x4d.swift` (1 violation) -- [x] `Sources/FirebladeMath/Matrix/Mat4x4f.swift` (1 violation) - -### 4. Opening Brace Spacing (`opening_brace`) - 6 violations -- [x] `Sources/FirebladeMath/Matrix/MatrixStorage+SIMD.swift` (6 violations) - -### 5. Multiline Arguments (`multiline_arguments`) - 6 violations -- [x] `Sources/FirebladeMath/Functions/matrix.swift` (6 violations) - -### 6. Computed Accessors Order (`computed_accessors_order`) - 4 violations -- [x] `Sources/FirebladeMath/Quat/QuaternionStorage+NO_SIMD.swift` (4 violations) - -### 7. Function Parameter Count (`function_parameter_count`) - 4 violations -- [x] `Sources/FirebladeMath/Matrix/Matrix4x4+Projections.swift` (4 violations) - -### 8. Blanket Disable Commands (`blanket_disable_command`) - 3 violations -- [x] `Sources/FirebladeMath/Matrix/MatrixStorage.swift` (1 violation) -- [x] `Sources/FirebladeMath/Matrix/Matrix4x4.swift` (1 violation) -- [x] `Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift` (1 violation) - -### 9. Identical Operands (`identical_operands`) - 2 violations -- [x] `Sources/FirebladeMath/Functions/sign.swift` (2 violations) - -### 10. Large Tuples (`large_tuple`) - 2 violations -- [x] `Sources/FirebladeMath/Matrix/Matrix3x3.swift` (1 violation) -- [x] `Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift` (1 violation) - -### 11. Variable Whitespace (`let_var_whitespace`) - 1 violation -- [x] `Sources/FirebladeMath/Quat/Quat.swift` (1 violation) - -### 12. File Length (`file_length`) - 1 violation -- [x] `Sources/FirebladeMath/Matrix/Matrix+Multiplication.swift` (1 violation) - -### 13. TODO Comment (`todo`) - 1 violation -- [x] `Sources/FirebladeMath/Matrix/MatrixStorage+NO_SIMD.swift` (1 violation) From 05b02f0fe905405c68550d84bcd56de64a8dd6d3 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 10:57:47 +0200 Subject: [PATCH 20/21] Dedicated lines --- Sources/FirebladeMath/Constants.swift | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/Sources/FirebladeMath/Constants.swift b/Sources/FirebladeMath/Constants.swift index 1c7b303..ca21d76 100644 --- a/Sources/FirebladeMath/Constants.swift +++ b/Sources/FirebladeMath/Constants.swift @@ -1,21 +1,35 @@ /// Factor to convert degrees to radians (Double). -@inlinable public var kDegreeToRadians64: Double { Double.pi / 180.0 } +@inlinable public var kDegreeToRadians64: Double { + Double.pi / 180.0 +} + /// Factor to convert degrees to radians (Float). -@inlinable public var kDegreeToRadians32: Float { Float(Double.pi / 180.0) } +@inlinable public var kDegreeToRadians32: Float { + Float(Double.pi / 180.0) +} /// Factor to convert radians to degrees (Double). -@inlinable public var kRadiansToDegree64: Double { 180.0 / Double.pi } +@inlinable public var kRadiansToDegree64: Double { + 180.0 / Double.pi +} + /// Factor to convert radians to degrees (Float). -@inlinable public var kRadiansToDegree32: Float { Float(180.0 / Double.pi) } +@inlinable public var kRadiansToDegree32: Float { + Float(180.0 / Double.pi) +} /// Extension to add constants to Float. extension Float { /// Half of Pi (π/2). - @inlinable public static var halfPi: Float { Float.pi * 0.5 } + @inlinable public static var halfPi: Float { + Float.pi * 0.5 + } } /// Extension to add constants to Double. extension Double { /// Half of Pi (π/2). - @inlinable public static var halfPi: Double { Double.pi * 0.5 } + @inlinable public static var halfPi: Double { + Double.pi * 0.5 + } } From 0b271e00d3b933773d6028a62c0bf1bafd544a10 Mon Sep 17 00:00:00 2001 From: Christian Treffs Date: Mon, 24 Aug 2026 11:02:18 +0200 Subject: [PATCH 21/21] build: disable redundantType and wrapMultilineStatementBraces in .swiftformat --- .swiftformat | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.swiftformat b/.swiftformat index 458ae5a..eb07e68 100644 --- a/.swiftformat +++ b/.swiftformat @@ -3,6 +3,8 @@ --commas inline --disable opaqueGenericParameters --disable preferKeyPath +--disable redundantType +--disable wrapMultilineStatementBraces --exclude .build,.github,.swiftpm,Scripts --extensionacl on-declarations --header strip