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

axis for unit quaterion given as (0, 0, 0) #86

Open
jodyxha opened this issue Jun 25, 2024 · 2 comments
Open

axis for unit quaterion given as (0, 0, 0) #86

jodyxha opened this issue Jun 25, 2024 · 2 comments

Comments

@jodyxha
Copy link

jodyxha commented Jun 25, 2024

Hi
I noticed that the axis of the unit quaternion (1,0,0,0) is returned as (0,0,0).

This code

from pyquaternion import Quaternion

q=Quaternion()`
print("q: %s"%q)`
print("axis %s, angle %f"%(q.axis,q.angle))`

produces this output:

q: 1.000 +0.000i +0.000j +0.000k`
axis [0. 0. 0.], angle 0.000000`

I think this behavior is not correct.
Of course, for an angle of 0 the axis is arbitrary, but it should not be [0,0,0]

@teodron
Copy link
Contributor

teodron commented Jun 26, 2024

The [0,0,0] is indeed not a unit vector. The axis is thus undetermined. Perhaps it would be best to indicate this situation through nan values instead of zeros and leave it up to the user of the library to indicate how they wish to proceed further. Another option would be through a special policy, e.g. offering a class property of the Quaernion class that users can override to their wishes, a property that could be named UndeterminedAxis or similar. By default, that could return nans instead of zeros, but the whole idea would be to have users configure the behavior. I also treated such an edge case a while ago by simply choosing 1,0,0 as an axis with no other consequence on my algorithm, but that is not a mathematically generally correct or without consequences. Thus, users should know that by default they will encounters nan values, but they can choose to tune the behavior if they really need a specific workaround and do not want to handle nans explicitly.

@jodyxha
Copy link
Author

jodyxha commented Jun 26, 2024 via email

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

2 participants