Skip to content
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

Rigid transforms using unit quaternions to represent rotation #382

Closed
Affie opened this issue Jun 15, 2021 · 9 comments
Closed

Rigid transforms using unit quaternions to represent rotation #382

Affie opened this issue Jun 15, 2021 · 9 comments

Comments

@Affie
Copy link
Contributor

Affie commented Jun 15, 2021

Related to the rabbit hole part of #358 where M = Sphere(3,ℍ) was mentioned to represent unit quaternions.

I was looking at using a semidirect product manifold of T(3) ⋊ Sphere(3,ℍ) or similar to compare with SE(3)
I cannot find a lot in the documentation on quaternions though.

Are quaternions implemented? If so how does the representation look?
Is there a Lie group/algebra implemented for Sphere or similar?

It is not something that is immediately needed at all, I was just curious.
I also don't know if it will be worth it yet.

@sethaxen
Copy link
Member

sethaxen commented Jun 15, 2021

Quaternions are implemented as a field that can underly a manifold (just enter ), but because there is not implementation of quaternions in Julia base and there are actually quite a few packages that implement quaternions, we don't commit to or depend on any one package. But there are examples in our tests where we have implemented and tested a quaternion manifold. (see e.g. https://github.com/JuliaManifolds/Manifolds.jl/blob/v0.5.4/test/projective_space.jl#L192-L300)

Semidirect products only make sense between two groups. So you would need to decorate a sphere with a relevant group operation in order to make this work. #25 experimented with doing just that, calling a Sphere decorated with a QuaternionicMultiplication a CompactSymplectic group.

The right thing to do here is probably to implement quaternions as a group. There are several equivalent ways to do this. One would be U(1, ℍ), that is, the group of 1x1 unitary matrices whose elements are quaternions. Such a matrix would contain a single unit quaternion. This would be provided by #345, but I don't plan to finish that PR soon. That PR would also provide SU(2), the special unitary group, which is technically a unit quaternion represented as a complex 2x2 matrix. Both of these suffer from requiring to use matrices instead of just a unit quaternion. Another way is to implement the compact symplectic group Sp(n,ℍ) as above, but this would technically be the same as U(1, ℍ), so should be a matrix.

The next component you would need is an action of one of these points upon a translation vector, similar to our RotationAction. With just those two implemented, the semidirect product of this group and T(3) should just work as well as SE(n).

@sethaxen
Copy link
Member

I should note that while this may sound complicated, it really isn't; the complication is just the design decision of which of these isomorphic groups to choose to implement.

@Affie
Copy link
Contributor Author

Affie commented Jun 15, 2021

Thank you, that answers all of my questions.

I'll wait for PR #345 then as I'm also not in a hurry and have enough to carry on with.

@Affie
Copy link
Contributor Author

Affie commented Jul 21, 2022

I see with the release of Manifolds v0.8.18 #345 was replaced by #499.

I think we should therefore be able to close this issue?
I just want to confirm that I should use U(1, ℍ), https://juliamanifolds.github.io/Manifolds.jl/stable/manifolds/group.html#Unitary-group?

@mateuszbaran
Copy link
Member

We don't quite have the quaternionic unitary group tested yet but thanks to @kellertuer 's work we are most of the way there.

@kellertuer
Copy link
Member

Oh, well spotted (and sorry that it took a year to find time to finish that, we are not that many active developers of stuff here).

What do we miss for the quaternionic case?

@mateuszbaran
Copy link
Member

What we miss is mostly docs, tests and maybe special-casing of some operations.

@mateuszbaran
Copy link
Member

I'll make a quick PR with that.

@sethaxen
Copy link
Member

Another option entirely is Sphere(0, ℍ), which is topologically the 3-sphere (see https://juliamanifolds.github.io/Manifolds.jl/stable/manifolds/sphere.html#Manifolds.Sphere) but represented as a vector containing a single unit quaternion.

julia> using Manifolds, Quaternions, LinearAlgebra

julia> M = Sphere(0, ℍ)
Sphere(0, ℍ)

julia> p = [one(QuaternionF64)]
1-element Vector{QuaternionF64}:
 QuaternionF64(1.0, 0.0, 0.0, 0.0, true)

julia> X = project(M, p, rand(QuaternionF64, 1))
1-element Vector{QuaternionF64}:
 QuaternionF64(0.0, 0.011772950124829262, 0.38155684156501735, 0.7096819017054976, false)

julia> is_vector(M, p, X)
true

julia> exp(M, p, X)
1-element Vector{QuaternionF64}:
 QuaternionF64(0.6925079449916864, 0.010539514911209379, 0.3415816748146443, 0.6353295398292529, false)

julia> q = exp(M, p, X)
1-element Vector{QuaternionF64}:
 QuaternionF64(0.6925079449916864, 0.010539514911209379, 0.3415816748146443, 0.6353295398292529, false)

julia> log(M, p, q)
1-element Vector{QuaternionF64}:
 QuaternionF64(0.0, 0.011772950124829262, 0.38155684156501735, 0.7096819017054976, false)

julia> norm(q)
0.9999999999999999

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants