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
ENH: Implemented Rotation.from_davenport and Rotation.as_davenport #17728
Conversation
@nmayorov As we discussed last time, I made this PR for the generalization of Euler angles. |
Alright, finally managed to fix all of the Sphinx problems. If there is any interest for this algorithm, I think it is ready. |
I don't know enough to evaluate the correctness of the algorithm, but I think it's certainly very interesting and I can see uses for it! My main suggestion was going to be to have tests that show equivalence between the euler angle functions and the davenport functions, but you've already got it in there! The only other thing I would say to add is a simple (non-Euler) test case where the target rotation matrix is hard-coded and something that could be verified by hand, rather than relying on programmatic test cases for everything. |
Hey there @scottshambaugh, thanks for your input! I think I might do it indeed when I have some time! I ended up not implementing any hard-coded case because I tried to keep it not too different from the tests for |
@nmayorov in case you have some time to review it, I implemented some time ago in this PR the generalization of my conversion algorithm to Davenport angles, in case you think this could be useful in Scipy. |
@evbernardes Yes, sorry I somehow forgot about this activity, I'll check it out. |
@evbernardes My thoughts on quick scan:
So I'd like to see a better generalization with Euler angle algorithms to reduce conceptual and technical duplication. |
Hello @nmayorov, thanks for your review! Using only the Davenport implementation is indeed a possibility I thought about. The only problem with that is that Do you think it is worth it anyways? PS.: For the minor unrelated change, I think this is a fault of my automatic linter, maybe a separate PR should be done in order to remove these spaces altogether... |
I see, I don't know how to judge it. Can you run |
My test has shown, that As there were efforts to speed up everything by using Cython (which reduced readability quite a bit) we probably should not pessimise Is there a way to reduce |
I think that will be all from me. Fix refguide checker complaints:
|
Oops! I think it's all good now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some pending approve required.
Is there something I should do, or just wait until someone approves it? |
I wish I knew 😄 I see that I can merge it now. I've send one approving review. I've left the last comment and it in the excellent state in my opinion. So I plan to merge it today or tomorrow. |
Alright, awesome! Once again, thank you for your time :) |
@evbernardes Great working with you. Come back with new ideas! |
Would you mind looking at #19512, I'm doing to modification to where/when the Gimbal Lock warning is emitted and as this touches code that was added by this recently thought that might be of interest. |
Reference issue
This is a follow-up to #17392.
What does this implement/fix?
Davenport angles are a generalization of Euler angles.
Implemented the function
Rotation.as_davenport
, and for convenience, an inverse function calledRotation.from_davenport
that makes internal calls toRotation.from_rotvec
but using the same type of parameters asRotation.as_davenport
.Additional information
Not any generalization is possible, basically we must have
dot(n1, n2) = dot(n2, n3) = 0
, like in Euler angles.Moreover, for Euler angles:
dot(n1, n3) = 0, 1
or-1
. For Davenport angles, this last can be any value between-1
and1
instead (Source).This is a follow-up to my implementation of a new algorithm for
Rotation.as_euler()
based on this paper (open access). I now implemented a slightly modified version of the same algorithm to compute the Davenport angles for a set of input axes in the function.In this implementation, there may be some set differences between the angles computed for the same axes by
Rotation.as_davenport
andRotation.as_euler
for some asymmetrical cases, but these different angles represent the same final rotation.