Open JinraeKim opened 1 year ago
The error is due to the normalization in the QuatRotation
's constructor. This normalization can be avoided with the second variable.
julia> using Rotations
julia> using Symbolics
julia> @variables q[1:4] = [1.0, 0, 0, 0]
1-element Vector{Symbolics.Arr{Num, 1}}:
q[1:4]
julia> r = QuatRotation(q..., false)
3×3 QuatRotation{Num} with indices SOneTo(3)×SOneTo(3)(Quaternion{Num}(q[1], q[2], q[3], q[4])):
q[1]^2 + q[2]^2 - (q[3]^2) - (q[4]^2) 2q[2]*q[3] - 2q[1]*q[4] 2q[1]*q[3] + 2q[2]*q[4]
2q[2]*q[3] + 2q[1]*q[4] q[1]^2 + q[3]^2 - (q[2]^2) - (q[4]^2) 2q[3]*q[4] - 2q[1]*q[2]
2q[2]*q[4] - 2q[1]*q[3] 2q[1]*q[2] + 2q[3]*q[4] q[1]^2 + q[4]^2 - (q[2]^2) - (q[3]^2)
julia> r^2
3×3 QuatRotation{Num} with indices SOneTo(3)×SOneTo(3)(Quaternion{Num}(q[1]^2 - (q[2]^2) - (q[3]^2) - (q[4]^2), 2q[1]*q[2], 2q[1]*q[3], 2q[1]*q[4])):
(q[1]^2 - (q[2]^2) - (q[3]^2) - (q[4]^2))^2 + 4(q[1]^2)*(q[2]^2) - 4(q[1]^2)*(q[3]^2) - 4(q[1]^2)*(q[4]^2) … 4(q[1]^2 - (q[2]^2) - (q[3]^2) - (q[4]^2))*q[1]*q[3] + 8(q[1]^2)*q[2]*q[4]
8(q[1]^2)*q[2]*q[3] + 4(q[1]^2 - (q[2]^2) - (q[3]^2) - (q[4]^2))*q[1]*q[4] 8(q[1]^2)*q[3]*q[4] - 4(q[1]^2 - (q[2]^2) - (q[3]^2) - (q[4]^2))*q[1]*q[2]
8(q[1]^2)*q[2]*q[4] - 4(q[1]^2 - (q[2]^2) - (q[3]^2) - (q[4]^2))*q[1]*q[3] (q[1]^2 - (q[2]^2) - (q[3]^2) - (q[4]^2))^2 + 4(q[1]^2)*(q[4]^2) - 4(q[1]^2)*(q[2]^2) - 4(q[1]^2)*(q[3]^2)
julia> principal_value(r)
ERROR: TypeError: non-boolean (Num) used in boolean context
Some methods (e.g. ^
) are supported, but I think most of the methods in Rotations.jl (e.g. principal_value
) does not work properly.
@hyrodium Thanks a lot! Then, in short, is it not encouraged to use symbolics for this package for now?
Then, in short, is it not encouraged to use symbolics for this package for now?
Yes, that's right. If Symbolics.jl had compatibility with Quaternions.jl (https://github.com/JuliaGeometry/Quaternions.jl/issues/123), the original error in this issue will be fixed, but I don't know whether other operations work correctly.
I think we have the following three ways to solve this problem:
I'm not familiar with Symbolics.jl, so I think the first and the last choices will be acceptable for now.
One should test if simply making Symbolics compatible with Quaternions resolves this issue. If so, a cleaner way would be to add Symbolics support with package extensions to Quaternions.
I was trying to use a symbolic to construct a
QuatRotation
but failed.Can anyone help me to debug this or is it a limitation of this package?