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

Add a rotation example into the documentation #215

Open
lemonJumps opened this issue Mar 31, 2023 · 1 comment
Open

Add a rotation example into the documentation #215

lemonJumps opened this issue Mar 31, 2023 · 1 comment

Comments

@lemonJumps
Copy link

Hiii!

I've been looking at how quaternions work for days, and I want to use them for a simple rotation, I know that you're supposed to do something like this:

q = quaternion.quaternion(0,0,0,0)
v = numpy.array([1,2,3])

print(q*v*q.conjugate())

and i know that x,y,z is a vector and w is the scaler and it's supposed to have a size of 1.
but uh, after looking at the docs, I have no idea what to actually do ;-;

I'm guessing most people simply want to take the despicable eurel angles, and use it to create quaternion to rotate an array of vectors :,D
I'd like to ask if you guys could add an example code of how to do this for smooth brained people like me.

thank you

@Denizantip
Copy link

Denizantip commented May 8, 2024

I would add on this.
There is more like common case when there can be multiple quaternions and multiple vectors. How to do rotation in that case?
Elementwise

quats = np.array([[0, 1, 0, 0],[0, 0, 1, 0]])
q = quaternion.as_quat_array(quats)
vectors = np.arange(6).reshape((-1, 3))
q * vectors * q.conjugate()

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