moble / quaternion

Add built-in support for quaternions to numpy
MIT License
611 stars 86 forks source link

possible docstring error #216

Closed petaflot closed 1 year ago

petaflot commented 1 year ago

This is about Euler angles. I have read (and hopefully understood) this page.

I am in the process of building an app/lib to generate toolpaths, it is working so far but I want to rewrite it with quaternions because AFAIK it's the only smart way to go. My project, using vispy as a frontend for the GUI, is located here: https://github.com/petaflot/superslice ; the GUI is supposedly nothing more than a HAL (hardware abstraction layer), the idea is to be able to generate machine instructions (G-code) for pretty much anything (be it XYZ cartesian 3D printers, 6-axii serial robots, delta bots.. you name it).

the project description (I just started rewriting it) is part in french, but there are images that give an idea of what it can do. the original project description is here https://www.engrenage.ch/i18n/projects/superslice/ and has at least one more image with a few renderings (these were made with matplotlib quite a while ago). I started this project because I couldn't find any software that could be used to draw one specific object I need to build.

For now, I am just trying to draw a cube, and apply transforms to it (rotate/translate/...).

this image is most important in my current understanding/paradigm (comments welcome) : https://github.com/petaflot/superslice/blob/main/doc/images/quaternion.svg

Describe the bug

the documentation says:

from_euler_angles(alpha_beta_gamma, beta=None, gamma=None)
    Improve your life drastically

    Assumes the Euler angles correspond to the quaternion R via

        R = exp(alpha*z/2) * exp(beta*y/2) * exp(gamma*z/2)

    The angles naturally must be in radians for this to make any sense.

Before I proceed, I want to make absolutely sure the formula above is not supposed to be R = exp(alpha*x/2) * exp(beta*y/2) * exp(gamma*z/2) ; if not, what are y and z supposed to be exactly? Either case, a drawing would be helpful (it would IMHO definitely be worth a thousand words here).

Note

I am not exactly a mathematician, one of the last things I was taught is complex numbers ; I've spontaneously used pairs of complex numbers for 3D stuff, now trying to figure out how it's really supposed to go (if that even means anything, cf. my comment about writing an RFC for this)

petaflot commented 1 year ago

Maybe I got it.. I pretty much overlooked the Tait-Bryan "variant" of Euler angles, so I was just doing it plain wrong. Will re-open issue of required.

moble commented 1 year ago

Just to be clear, the docstring is correct, and your suggested xyz ordering is not what this function does.