mirror of
https://github.com/apple/swift-numerics
synced 2026-11-30 05:28:47 +00:00
Add property tests on quaternions
This commit is contained in:
1 parent
99a7c6113d
commit
22ec1b960b
2 files changed
+121
-4
No files matched your search
@@ -357,8 +357,7 @@ extension Quaternion: Hashable {
|
||||
// FloatingPoint does not refine Codable, so this is a conditional conformance.
|
||||
extension Quaternion: Decodable where RealType: Decodable {
|
||||
public init(from decoder: Decoder) throws {
|
||||
var unkeyedContainer = try decoder.unkeyedContainer()
|
||||
self.init(from: try unkeyedContainer.decode(SIMD4<RealType>.self))
|
||||
try self.init(from: SIMD4(from: decoder))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,6 +409,7 @@ extension Quaternion {
|
||||
/// - `.lengthSquared`
|
||||
@_transparent
|
||||
public var length: RealType {
|
||||
guard isFinite else { return .infinity }
|
||||
return .sqrt(lengthSquared)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user