Skip to content

Conversation

@hyrodium
Copy link
Collaborator

@hyrodium hyrodium commented Oct 26, 2022

This PR removes rotation-related functions. (closes #86)
Note that the documentation is failing to build because Rotations.jl assumes Quaternion has the norm field. I'd like to wait for JuliaGeometry/Rotations.jl#243.

Edit: The documentation does not depend on Rotations.jl now.

@hyrodium hyrodium mentioned this pull request Dec 1, 2022
@hyrodium hyrodium mentioned this pull request Dec 1, 2022
@codecov
Copy link

codecov bot commented Dec 1, 2022

Codecov Report

Merging #111 (b7aa354) into main (9c62d64) will increase coverage by 0.76%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #111      +/-   ##
==========================================
+ Coverage   98.44%   99.20%   +0.76%     
==========================================
  Files           1        1              
  Lines         193      126      -67     
==========================================
- Hits          190      125      -65     
+ Misses          3        1       -2     
Impacted Files Coverage Δ
src/Quaternion.jl 99.20% <ø> (+0.76%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@sethaxen sethaxen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have more suggestions later, but here are a few.

Rotations with quaternions have the following properties:

* An additive inverse of a unit quaternion represents the same rotation.
* Unit quaternion is more efficient to represent rotation than rotation matrix.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Unit quaternion is more efficient to represent rotation than rotation matrix.
* A unit quaternion is more efficient for representing a rotation than a rotation matrix.

And what if we made it explicit that the efficiency is that it uses only 4 numbers with 1 constraint instead of 9 numbers with 6 constraints?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the part with:

  • A unit quaternion (4 real numbers) is more efficient for representing a rotation than a rotation matrix (9 real numbers).
    • This results in higher computational performance in terms of time, memory usage, and accuracy.

* High computation performance, both in time and memory
* A conjugate of a unit quaternion represents the inverse rotation.
* The quaternion has unit length, so conjugate and multiplicative inverse is the same.
* The set of unit quaternion ``\left\{w + ix + jy + kz \in \mathbb{H} \ | \ x, y, z \in \mathbb{R} \right\} \simeq S^3`` is isomorphic to ``SU(2)``.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen this explained differently in a few places. But I would probably steer away from calling the set of unit quaternions S^3. It's isomorphic to it, but for one thing, we're not working with unit vectors. Strictly speaking, I'd say it's U(1, ℍ).

Copy link
Collaborator Author

@hyrodium hyrodium Dec 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the suggestion! I was really looking for the short symbol for the set of unit quaternions, and $U(1, ℍ)$ looks great!

* A conjugate of a unit quaternion represents the inverse rotation.
* The quaternion has unit length, so conjugate and multiplicative inverse is the same.
* The set of unit quaternion ``\left\{w + ix + jy + kz \in \mathbb{H} \ | \ x, y, z \in \mathbb{R} \right\} \simeq S^3`` is isomorphic to ``SU(2)``.
* These groups are homomorphic to ``SO(3)``.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to define SO(3). Can this and the below statement be merged?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


## Rotate a vector with a quaternion
A vector ``v = (v_x, v_y, v_z)`` can be rotated by a unit quaternion ``q``.
The rotated vector ``v' = (v_x', v_y', v_z')`` can be obtained as
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we said R(q)v instead of v' to avoid confusion with adjoint?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The group of unit quaternions $U(1,\mathbb{H})$ acts in 3-dimensional Euclidean space without involving the orthogonal group $SO(3)$, so I thought it seems better to avoid the R(q)v notation.

I have replaced (v, v′) with (u,v).

return pnew
end
function rotmatrix_from_quat(q::Quaternion)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor point, but I prefer we avoid _from_quat unless necessary, since in Julia, _from_XXX is handled by the type constraint in the method overload, so it's redundant.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with that as the common manner in the Julia language. However this is just documentation and readers cannot check the methods of the function by running methods(XXX), and I thought explicit XXX_from_YYY is a little better.

@hyrodium
Copy link
Collaborator Author

hyrodium commented Dec 6, 2022

@sethaxen Thank you for the corrections, and sorry for my poor English:sweat_smile:. I think we can improve the documentation after the release of v0.7.0 if there are no major problems in this PR.

@sethaxen
Copy link
Collaborator

sethaxen commented Dec 6, 2022

I think we can improve the documentation after the release of v0.7.0 if there are no major problems in this PR.

You're right, no problem at all! LGTM.

@hyrodium hyrodium merged commit bdf34b9 into JuliaGeometry:main Dec 7, 2022
@hyrodium hyrodium mentioned this pull request Dec 7, 2022
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

Successfully merging this pull request may close these issues.

Drop inefficient functions for rotation?

2 participants