@@ -309,24 +309,40 @@ extension Quaternion {
309309 }
310310 }
311311
312- /// Rotates given vector by this quaternion.
312+ /// Transforms a vector by this quaternion.
313313 ///
314- /// As quaternions can be used to represent three-dimensional rotations, it is
315- /// is possible to also rotate a three-dimensional vector by a quaternion. The
316- /// rotation of an arbitrary vector by a quaternion is known as an action.
314+ /// Quaternions are frequently used to represent three-dimensional
315+ /// transformations, and thus are used to transform vectors in
316+ /// three-dimensional space. The transformation of an arbitrary vector
317+ /// by a quaternion is known as an action.
318+ ///
319+ /// The canonical way of transforming an arbitrary three-dimensional vector
320+ /// `v` by a quaternion `q` is given by the following [formula][wiki]
321+ ///
322+ /// p' = qpq⁻¹
323+ ///
324+ /// where `p` is a *pure* quaternion (`real == .zero`) with imaginary part equal
325+ /// to vector `v`, and where `p'` is another pure quaternion with imaginary
326+ /// part equal to the transformed vector `v'`. The implementation uses this
327+ /// formular but boils down to a simpler and faster implementation as `p` is
328+ /// known to be pure and `q` is assumed to have unit length – which allows
329+ /// simplification.
317330 ///
318331 /// - Note: This method assumes this quaternion is of unit length.
319332 ///
320333 /// Edge cases:
321334 /// -
322- /// - If `vector` is `.infinity` in any of the lanes or all, the returning
335+ /// - For any quaternion `q`, even `.zero` or `.infinity`, if `vector` is
336+ /// `.infinity` or `-.infinity` in any of the lanes or all, the returning
323337 /// vector is `.infinity` in all lanes:
324338 /// ```
325- /// Quaternion(rotation: .zero) == .zero
339+ /// SIMD3(-.infinity,0,0) * q == SIMD3(.infinity,.infinity,.infinity)
326340 /// ```
327341 ///
328342 /// - Parameter vector: A vector to rotate by this quaternion
329343 /// - Returns: The vector rotated by this quaternion
344+ ///
345+ /// [wiki]: https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation#Using_quaternion_as_rotations
330346 @inlinable
331347 public func act( on vector: SIMD3 < RealType > ) -> SIMD3 < RealType > {
332348 guard vector. isFinite else { return SIMD3 ( repeating: . infinity) }
0 commit comments