-
Notifications
You must be signed in to change notification settings - Fork 50
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
Allow rotation of Vector3d object by Rotation object. #453
Comments
A virtual diffractometer sounds cool, please let us know when you make it available so we can list in among related projects in the docs.
This is the canonical way of rotating vectors in orix. In this example, one single vector is rotated by many orientations to return many vectors. Is this what you're after? If so it is already available? I realise that it is not covered specifically in the API reference of I never use
Yes, we should add a |
Ah beans, you're right. Sorry, I should have tried this before making an Issue. I saw Also, quick test shows it broadcasts correctly for multiple vectors as well, so even better: from orix.vector.vector3d import Vector3d
from orix.quaternion import Rotation
import numpy as np
v = Rotation([1, 1, 1, 0]).axis
v_repeat = Vector3d(np.tile(v.data, 2).reshape(2, 3))
v_rand = Rotation.random(2).axis
r = Rotation([0, 2, 3, 1])
r_repeat = Rotation(np.tile(r.data, 2).reshape(2, 4))
r_rand = Rotation.random(2)
print(r*v)
print(r*v_repeat)
print(r*v_rand)
print(r_repeat*v_repeat)
print(r_repeat*v_rand)
print(v*r) As for the rest of your comments:
I agree,
That's a much better way to handle things I think. thank your for alerting me to this.
I can add that as well, small addition. |
I'm sure many people do this, which is understandable since we don't show on the The initial rotation of vector by a quaternion was written by the orix originator I believe, Ben Martineau. Rotation was performed using v' = q * v * q^-1 (according to this formula). @harripj replaced this "hard-coded" implementation with the current numpy-quaternion one. Removing Yes, please go ahead and add |
I am writing a virtual diffractometer using Orix, and it would be useful to allow rotation of a vector by a rotation, ideally by doing:
Three points about this.
First, Vector3d.rotate currently uses
Vector3d
andangle
pairs to do a rotation. What is the best way to deal with this? should rotate accept either rotation or vector/angle pairs, or should users be expected to cast vector/angles to rotations prior to the call?Second, this loosely ties in with the points about #139 and #249, which can be broadly summarized as "what are the best universal rules for how any two orix objects use
__mul__
, and how should we implement those rules in the code" I think this use case is simple:But I want to know if anyone (especially @hakonanes , @pc494 , and @harripj ) disagree
Third, there are two ways to do the rotation, and I think the numpy-quaternion.rotate_vectors notes sum them up perfectly:
so, we could do the math the easy way or the efficient way.
Thoughts?
The text was updated successfully, but these errors were encountered: