Skip to content

Commit

Permalink
Reworked methods to document new Quaternion constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
brainandforce committed Nov 12, 2024
1 parent 6115195 commit 9290e59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/src/api/extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
```
Expand Down
6 changes: 5 additions & 1 deletion ext/CliffordNumbersQuaternionsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9290e59

Please sign in to comment.