Orientation from align vectors #400
Replies: 3 comments 3 replies
-
Hi @anderscmathisen, thank you for suggesting this functionality. Pretty sure there are others in your situation, so such a class method should be useful to have in orix! If others agree, I suggest you open a PR adding this method to the
I believe you are right there. I suggest to just wrap Regarding the implementation, we could return the other returns from SciPy if the user asked for it in a |
Beta Was this translation helpful? Give feedback.
-
This would be a super helpful function for me as well, as parent/child orientation relationships are often similarly given as vectors to avoid confusion, but MDF and ODF calculations require that same info as misorientations. Two suggestions, take them or leave them:
notably, orix follows the (s, v1,v2,v3) convention while scipy orders theirs as (v1,v2,v3,s). These are two of those 8 valid hemispheres. I THINK this is the magic formula to convert between the two, but no guarantees: With that in mind, I would instead suggest the following version of your function:
|
Beta Was this translation helpful? Give feedback.
-
I am currently working on a PR for this. First of all, I have started to implement the function as part of the Rotation class and not Quaternion. This might be me not understanding the philosophy of Orix, but I noticed that the Quaternion class defined in Second, most of the One possible implementation is to have a and b have a shape of (M,N,3), where M is the number of rotations we want returned and N is the number of vectors in each set. rotations = []
for a_m, b_m in a, b:
rotation = scipy.align_vectors(a_m,b_m)
orix_rotation = convert_to_orix(rotation)
rotations.append(orix_rotation)
return rotations Do you have any suggestions here? Is it important to support creating arrays of rotations? |
Beta Was this translation helpful? Give feedback.
-
I have been trying to find a way to initialize an Orix Orientation object from an indexed diffraction pattern. My thinking is that if we know that u1 || v1 and u2 || v2 where u are Crystal directions (from the indexed diffraction pattern) and v are the sample directions (known from the x and y direction of the image of the diffraction pattern), then enough information is provided to determine the orientation of the crystal.
Scipys rotation object has a method for initializing a Rotation object from two sets of two vectors, where the rotation is described as the rotation which takes one from the first set of two vectors, to the second. It does this using Kabsch algorithm (https://en.wikipedia.org/wiki/Kabsch_algorithm).
Essentially what I am looking for is a similar function in Orix. I have made a very simple wrapper for scipys function to get a orix Orientation object:
I have also tried to code up some algorithm to get this Orientation myself. If the vectors in both sets we are trying to align are normal to each other, then an algorithm which first finds the rotation g1 which takes u1 to v1, and then finds the rotation g2 which takes the vector (g1 * u1) to v2 (which will just be a rotation about the vector v1) should work as the full rotation will be g = g2 * g1. However, if the vectors in the two sets are not normal, it seems to me that this algorithm will not work.
Would the wrapper above be a useful addition to the Orientation object in Orix? Or do you have any suggestions to how such a function could be implemented in Orix in the best way possible?
Beta Was this translation helpful? Give feedback.
All reactions