-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecated UnitQuaternion
doesn't work
#208
Comments
Also, I'm happy that we're using this name 🙂 |
Sorry - which name do you prefer? |
The new one, |
Should we add something like this and release function Base.getproperty(q::QuatRotation, f::Symbol)
if f == :w
getfield(q,:q).s
elseif f == :x
getfield(q,:q).v1
elseif f == :y
getfield(q,:q).v2
elseif f == :z
getfield(q,:q).v3
else
getfield(q,f)
end
end |
Related: #175 (comment) |
I'd be in favor of deprecating field access completely -- the indirection of having to say I suggest we define a method to_quaternion(r::QuatRotation)::Quaternions.Quaternion = r.q that returns the underlying quaternion. One advantage of this over having only |
We already have the following conversion. Isn't this enough? julia> using Rotations, Quaternions
julia> q = rand(QuatRotation)
3×3 QuatRotation{Float64} with indices SOneTo(3)×SOneTo(3)(Quaternion{Float64}(0.182754, 0.632691, -0.155473, 0.736295, true)):
-0.132605 -0.465855 0.874869
0.072389 -0.884858 -0.460202
0.988522 0.00230565 0.15106
julia> Quaternion(q)
Quaternion{Float64}(0.1827539852714259, 0.6326913349141059, -0.155472992405557, 0.736295324054472, true) I think this should be documented. |
Ah, we still missing this converison. julia> convert(Quaternion, q)
ERROR: MethodError: Cannot `convert` an object of type
QuatRotation{Float64} to an object of type
Quaternion
Closest candidates are:
convert(::Type{T}, ::Base.TwicePrecision) where T<:Number at twiceprecision.jl:250
convert(::Type{T}, ::AbstractChar) where T<:Number at char.jl:180
convert(::Type{T}, ::CartesianIndex{1}) where T<:Number at multidimensional.jl:136
...
Stacktrace:
[1] top-level scope
@ REPL[11]:1 |
I have also run into this issue because of a package that I use (MeshCat.jl). What is the recommendation going forward? E.g., what is the ideal way of rewriting this line from Rotations.jl |
@ferrolho, I think the most general answer to that is "first coerce (or, once #208 (comment) is implemented, function js_quaternion(q::UnitQuaternion)
q_ = Quaternions.Quaternion(q)
return [q_.v1, q_.v2, q_.v3, q_.s]
end @hyrodium, it might be worth adding a |
Thank you, @bzinberg. :) And, FWIW, I agree that a convenient |
oh, and change the name |
Isn't it enough with |
We can always use |
"Always," until we want to change the under-the-hood details of Not a strong opinion on this, just sharing my thoughts. |
Yes, in principle that's enough. However, the user has to be careful to note the order of arguments returned by this function (which should be in the docstring and any future changes to it should be considered breaking changes; and there are different orders in widespread use). I like the idea of having a method (or just field access, if we decide to make |
I agree with that.
I understand, but I think
Hmm, I think |
UnitQuaternion
is now a deprecated alias forQuatRotation
:Rotations.jl/src/deprecated.jl
Line 2 in 89e4dd4
However, field access doesn't work the same as it did in v1.0.x, as
w
,x
,y
,z
no longer directly stored as fields in the struct. This makes the behavior ofUnitQuaternion
in v1.1.0 backward-incompatible with v1.0.x. Given that users ofUnitQuaternion
will already need to update their codebase, how about we just removeUnitQuaternion
entirely?The text was updated successfully, but these errors were encountered: