From bd99cdeffb1949ef640b8683bd11d70f5d51e3fb Mon Sep 17 00:00:00 2001 From: Markus Winter Date: Thu, 18 Jun 2020 08:23:13 +0200 Subject: [PATCH] Add links to documentation and fix typo in comment --- Sources/QuaternionModule/Transformation.md | 7 ++++++- Tests/QuaternionTests/TransformationTests.swift | 10 +++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Sources/QuaternionModule/Transformation.md b/Sources/QuaternionModule/Transformation.md index 4d9a45c..6282733 100644 --- a/Sources/QuaternionModule/Transformation.md +++ b/Sources/QuaternionModule/Transformation.md @@ -1,6 +1,6 @@ # Transformation -`Transformation.swift` encapsulates an API for working with other representations of transformations, such as *Angle-Axis*, *Polar* and *Rotation Vector*. The API provides operations to convert from these representations to `Quaternion` and vice versa. +`Transformation.swift` encapsulates an API for working with other representations of transformations, such as [*Angle-Axis*][angle_axis_wiki], [*Polar*][polar_wiki] and [*Rotation Vector*][rotation_vector_wiki]. The API provides operations to convert from these representations to `Quaternion` and vice versa. Additionally, the API provides a method to directly rotate an arbitrary vector by a quaternion and thus avoids the calculation of an intermediate representation to any other form in the process. ## Policies @@ -16,3 +16,8 @@ Additionally, the API provides a method to directly rotate an arbitrary vector b - the `axis` property of `angle == .zero` is `RealType.nan` in all lanes. - the `rotationVector` property of `angle == .zero` is `RealType.nan` in all lanes. + +[angle_axis_wiki]: https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation#Recovering_the_axis-angle_representation +[polar_wiki]: https://en.wikipedia.org/wiki/Polar_decomposition#Quaternion_polar_decomposition +[rotation_vector_wiki]: https://en.wikipedia.org/wiki/Axis–angle_representation#Rotation_vector + diff --git a/Tests/QuaternionTests/TransformationTests.swift b/Tests/QuaternionTests/TransformationTests.swift index 2047909..77a535c 100644 --- a/Tests/QuaternionTests/TransformationTests.swift +++ b/Tests/QuaternionTests/TransformationTests.swift @@ -237,15 +237,15 @@ final class TransformationTests: XCTestCase { let vrot = (q // q * Quaternion(imaginary: vector) // v (pure quaternion) * q.conjugate // q⁻¹ (as q is of unit length, q⁻¹ == q*) - ).imaginary // the result is pure quaternion with v' == imaginary + ).imaginary // the result is a pure quaternion with v' == imaginary XCTAssertTrue(q.act(on: vector).x.isFinite) XCTAssertTrue(q.act(on: vector).y.isFinite) XCTAssertTrue(q.act(on: vector).z.isFinite) // Test for sign equality on the components to see if the vector rotated - // to the correct quadrant and if the vector is of equal in length, - // instead of testing component equality – as they are hard to compare - // with proper tolerance + // to the correct quadrant and if the vector is of equal length, instead + // of testing component equality – as they are hard to compare with + // proper tolerance XCTAssertEqual(q.act(on: vector).x.sign, vrot.x.sign) XCTAssertEqual(q.act(on: vector).y.sign, vrot.y.sign) XCTAssertEqual(q.act(on: vector).z.sign, vrot.z.sign) @@ -274,7 +274,7 @@ final class TransformationTests: XCTestCase { // An axis perpendicular to the vector, so all lanes are changing equally let axis = SIMD3(1/2,0,-1/2) - // Create a value close (somewhat) close to .greatestFiniteMagnitude + // Create a value (somewhat) close to .greatestFiniteMagnitude let scalar = T( sign: .plus, exponent: T.greatestFiniteMagnitude.exponent, significand: 1.999999