-
Notifications
You must be signed in to change notification settings - Fork 44
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
UnitQuaternion scalar division #140
Conversation
So this should be defined by matrix - scalar division, as a julia> r = one(UnitQuaternion)
3×3 UnitQuaternion{Float64} with indices SOneTo(3)×SOneTo(3)(1.0, 0.0, 0.0, 0.0):
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
julia> r / 2
3×3 StaticArrays.SMatrix{3, 3, Float64, 9} with indices SOneTo(3)×SOneTo(3):
0.5 0.0 0.0
0.0 0.5 0.0
0.0 0.0 0.5 I think the UnitQuaternion invariants should be maintained by all operations, and never return a non-unit quaternion. |
Thanks for the reply! When you say |
I think the current |
For the multiplication of quaternion, Quaternions.jl will be helpful. I think it's better to add dependency on the package and support type comvesion from |
Gosh! Yes. julia> one(UnitQuaternion)
3×3 UnitQuaternion{Float64} with indices SOneTo(3)×SOneTo(3)(1.0, 0.0, 0.0, 0.0):
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
julia> 3 * one(UnitQuaternion)
3×3 UnitQuaternion{Float64} with indices SOneTo(3)×SOneTo(3)(3.0, 0.0, 0.0, 0.0):
9.0 0.0 0.0
0.0 9.0 0.0
0.0 0.0 9.0 These are meant to follow matrix multiplication, etc.
Right. This is why scattered through the issues and PRs here you'll find discussion of With the new release I think you can do
Yeah I can see that the status quo is confusing people and even we've got it muddled now. I propose struct UnitQuaterion{T} <: Rotation{3, T}
quat::Quaternions.Quaternion
end so that it's a wrapper around the Quaternions.jl quaternion, and conversion back-and-forth is trivial. You can use the quaternion algebra or matrix algebra as you wish. |
I will close this PR because we have removed |
This adds scalar division for a
UnitQuaternion
q
and scalars
. So far, only scalar multiplication had been implemented.q/s
ands\q
are just element-wise division,s/q
andq\s
use the inverse for regular quaternions since multiplication and division with scalars might result in non-unit quaternions.