Skip to content

Commit c3206e8

Browse files
markuswntrstephentyrone
authored andcommitted
Rename rotationEquals to transformationEquals on Quaternion
1 parent bad87dc commit c3206e8

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

Sources/QuaternionModule/Quaternion.swift

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,9 @@ extension Quaternion: Hashable {
404404
/// - Important:
405405
/// Quaternions are frequently used to represent 3D transformations. It's
406406
/// important to be aware that, when used this way, any quaternion and its
407-
/// negation represent the same transformation, but they do not compare equal
408-
/// using `==` because they are not the same quaternion.
409-
/// You can compare quaternions as 3D transformations using `transformEquals()`.
407+
/// negation represent the same transformation, but they do not compare
408+
/// equal using `==` because they are not the same quaternion. You can
409+
/// compare quaternions as 3D transformations using `transformEquals()`.
410410
@_transparent
411411
public static func == (lhs: Quaternion, rhs: Quaternion) -> Bool {
412412
// Identify all numbers with either component non-finite as a single "point at infinity".
@@ -418,21 +418,19 @@ extension Quaternion: Hashable {
418418
return lhs.components == rhs.components
419419
}
420420

421-
/// Rotation equality comparison
421+
/// Transformation equality comparison
422422
///
423-
/// This method tests for rotation-wise equality in *R³*, where both `q == q`
424-
/// but also `q == -q` are `true`.
423+
/// Returns a Boolean value indicating whether the 3D transformations of this
424+
/// quaternion equals the 3D transformation of `other`.
425425
///
426-
/// - Parameters:
427-
/// - other: The value to compare.
428-
/// - Returns: Boolean value indicating whether the rotation in *R³* of this
429-
/// quaternion equals the rotation of `other`.
426+
/// - Parameter other: The value to compare.
427+
/// - Returns: True if the transformation of this quaternion equals `other`.
430428
@_transparent
431-
public func rotationEquals(_ other: Quaternion) -> Bool {
429+
public func transformEquals(_ other: Quaternion) -> Bool {
432430
// Identify all numbers with either component non-finite as a single "point at infinity".
433431
guard isFinite || other.isFinite else { return true }
434-
// For finite numbers, equality is defined componentwise. Cases where
435-
// only one of lhs or rhs is infinite fall through to here as well, but this
432+
// For finite numbers, equality is defined componentwise. Cases where only
433+
// one of lhs or rhs is infinite fall through to here as well, but this
436434
// expression correctly returns false for them so we don't need to handle
437435
// them explicitly.
438436
return components == other.components || components == -other.components
@@ -452,7 +450,7 @@ extension Quaternion: Hashable {
452450
// (while unfortunately producing some collisions for people who are not,
453451
// but not in too catastrophic of a fashion).
454452
if isFinite {
455-
transformCanonicalized.hash(into: &hasher)
453+
transformCanonicalized.components.hash(into: &hasher)
456454
} else {
457455
hasher.combine(RealType.infinity)
458456
}

Tests/QuaternionTests/PropertyTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ final class PropertyTests: XCTestCase {
161161
),
162162
]
163163
for (lhs, rhs) in rotations {
164-
XCTAssertTrue(lhs.rotationEquals(rhs))
164+
XCTAssertTrue(lhs.transformEquals(rhs))
165165
}
166166
}
167167

0 commit comments

Comments
 (0)