mirror of
https://github.com/apple/swift-numerics
synced 2026-11-27 05:04:26 +00:00
Add links to documentation and fix typo in comment
This commit is contained in:
1 parent
5b96cba10e
commit
bd99cdeffb
2 files changed
+11
-6
No files matched your search
@@ -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
|
||||
|
||||
@@ -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<T>(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
|
||||
|
||||
Reference in new issue
Block a user