JuliaGeometry / Quaternions.jl

A Julia implementation of quaternions
https://juliageometry.github.io/Quaternions.jl
MIT License
116 stars 37 forks source link

inv not working on Quaternion{Num} #123

Open knuesel opened 1 year ago

knuesel commented 1 year ago

The inv function doesn't work for quaternions of Symbolics.Num type:

julia> using Quaternions, Symbolics

julia> q = quat(Num.([0,0,0,1])...)
Quaternion{Num}(0, 0, 0, 1)

julia> inv(q)
ERROR: MethodError: /(::Quaternion{Num}, ::Num) is ambiguous. Candidates:
  /(a::Number, b::Num) in Symbolics at /home/j/.julia/packages/SymbolicUtils/qulQp/src/methods.jl:71
  /(q::Quaternion, x::Real) in Quaternions at /home/j/.julia/packages/Quaternions/kqEsP/src/Quaternion.jl:123
Possible fix, define
  /(::Quaternion, ::Num)
Stacktrace:
 [1] inv(q::Quaternion{Num})
   @ Quaternions ~/.julia/packages/Quaternions/kqEsP/src/Quaternion.jl:143
 [2] top-level scope
   @ REPL[3]:1
hyrodium commented 1 year ago

I think the method inv(q::Quaternion) should be defined in Symbolics.jl because:

sethaxen commented 1 year ago

On Julia v1.9 this could be done by setting up a weakdep of Symbolics on Quaternions or the other way around. I'm not certain which makes more sense.

hyrodium commented 9 months ago

It seems the issue is not just implementations of /(::Quaternion{Num}, ::Num), inv(::Quaternion{Num}) etc.

For example, we need a quaternionic version of Symbolics.ComplexTerm, so the problem is not that simple and that should not be finished in this package.