From 9290e597cfb1fcff86ebd512dc87656532a02f47 Mon Sep 17 00:00:00 2001 From: Brandon Flores Date: Tue, 12 Nov 2024 14:48:24 -0600 Subject: [PATCH] Reworked methods to document new `Quaternion` constructor --- docs/src/api/extensions.md | 2 +- ext/CliffordNumbersQuaternionsExt.jl | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/src/api/extensions.md b/docs/src/api/extensions.md index 2f17db7..0730c88 100644 --- a/docs/src/api/extensions.md +++ b/docs/src/api/extensions.md @@ -3,7 +3,7 @@ ## [Quaternions.jl] ```@docs -(::Type{H})(::AbstractCliffordNumber{VGA(3)}) where H<:Quaternion +Quaternion(::AbstractCliffordNumber{VGA(3)}) Quaternions.slerp(::AbstractCliffordNumber{VGA(3)}, ::AbstractCliffordNumber{VGA(3)}, ::Real) Quaternions.slerp(::AbstractCliffordNumber{VGA(3)}, ::Quaternion, ::Real) ``` diff --git a/ext/CliffordNumbersQuaternionsExt.jl b/ext/CliffordNumbersQuaternionsExt.jl index bc26950..b978844 100644 --- a/ext/CliffordNumbersQuaternionsExt.jl +++ b/ext/CliffordNumbersQuaternionsExt.jl @@ -31,17 +31,21 @@ end (::Type{H})(c::EvenCliffordNumber{VGA(3)}) where H<:Quaternion = H(Tuple(c)...) +# TODO: simplify this with functor syntax. Documenter.jl issues prevent this at the moment """ Quaternion(c::AbstractCliffordNumber{VGA(3)}) Quaternion{T}(c::AbstractCliffordNumber{VGA(3)}) Constructs a quaternion from an element of the algebra of physical space, the 3D geometric algebra with a positive-definite signature whose even subalgebra is isomorphic to the quaternion algebra ℍ. -Any odd-grade coefficients of `c` are lost. +Any odd-grade coefficients of `c` are lost. If the type parameter `T` is supplied, the scalars of +the input are converted to type T. If loss of odd-grade coefficients should throw an error, use `convert(Quaternion, c)` or `convert(Quaternion{T}, c)` instead of the constructor. """ +Quaternion(c::AbstractCliffordNumber{VGA(3)}) = Quaternion(EvenCliffordNumber{VGA(3)}(c)) + function (::Type{H})(c::AbstractCliffordNumber{VGA(3)}) where H<:Quaternion return H(EvenCliffordNumber{VGA(3)}(c)) end