Find rotation to align two vectors by rotation about two arbitrary axesby Johan_L Tags: align, rotationaxes, rotations, vectors 

#1
Feb1012, 02:05 AM

P: 4

Hello,
Background: We have a machine with two rotational axes (b,c) attached to each other. By design the B axis is rotating about the Yaxis and the caxis is attached on top of the b axis. Ideally the axes are orthogonal but in practice they are not. However we can measure the directions of the axes. Hence we have the axes of rotations described as two vectors. The target is to align an arbitrary vector that is attached to the caxis of rotation to a vector that is described in the global coordinates by changing the rotation angle of the b and c axis. We can construct the full rotation matrix but how do we find the angles b and c that aligns the vectors. From CAD we can see that there are multiple solutions.0 16 We can find numerous examples on how to get one angle and one axis of rotation from a rotation matrix. We can also find a lot of examples on how to split the transform into three Euler angles. We know that the problem is possible to solve numerically but is there a closed form solution? 



#2
Feb1012, 02:28 AM

P: 4,570

Hey Johan L and welcome to the forums.
The best way I see to do this is to use the axisangle method of rotation. Basically this works by having an axis of rotation and an angle which you rotate an existing point (or vector depending on your notation) around an axis by a specific angle. The way to do this mathematically is well known and you can use matrix methods to do this or you can use quaternion methods and then convert the results to a matrix which you then just use matrix multiplication. Now to get the axis of rotation, what you need to do is take the cross product of the two vectors and normalize the result. This will give you a vector that is perpendicular to both the start vector and the final vector which means you have a vector which to 'rotate around'. Do get the angle you use the dot product of the two vectors (final and start) and make sure you are working with normalized vectors so that you get the right term (i.e. cos(theta) instead a cos(theta) for some value of a <> 1). That should do the trick. 



#3
Feb1012, 02:42 AM

P: 4

Thanks for the answer that would give us one axis of rotation and the corresponding angle. Our hardware constrains us to rotation about b and c and hence we need to find those two angles.
Is there a way to "split" the rotation calculated by the method you suggest into rotations b and c? 



#4
Feb1012, 03:03 AM

P: 4,570

Find rotation to align two vectors by rotation about two arbitrary axesSo once you have found your vector above, you now do this in the context of your baxis and your caxis. This time however you have got the actual axis of rotation so now you just have to find the angles. There needs to be some level of orthogonality (i.e. the axis are not linearly dependent) which of course is the case due to the physical nature of the design. It might actually be a good idea to use composition of matrices and then finding the appropriate inverse to get your final transformation. How much do you know about composing matrices? Have you ever worked with matrix composition to compose rotations before? I don't have the solution in front of me right now, but basically what I would do is to create a composition of the rotations that fit the system (so basically what this means is that you have a system Ax = b where A represents the linear system that transforms x to b or start vector to finish vector) and then you decompose A into submatrices that correspond to rotations around b and c axis. So given Ax = b, and A = BC, then this means you want to find (A^1) = (BC)^1 where B represents the rotation information around axis B and C represents the one for axis C. For these matrices you fill in the appropriate information for matrices B and C based on the axisangle formulation of the matrix (for this see: http://en.wikipedia.org/wiki/Rotatio..._to_axisangle) Then you will get a linear system involving your two angles which you can solve with linear algebra techniques. If you need any further help I'll do my best to help you. 



#5
Feb1012, 05:03 AM

P: 4

We have gotten about that far. y=Rb.Rc.x
We can as you say calculate a transformation R with a rotation axis, the cross product between the vectors and find the angle acos(dotproduct) The problem is to find angles b and c given that. I guess the question really is how hard this is, we are intermediate skill at best. If this leads to complicated calculations we will just go for a numerical solution straight away. 



#6
Feb1012, 05:10 AM

P: 4,570

If you want to know more about the specifics, what you can do is take the system and expand out the algebra to get systems that are in terms of x and y (x being angle for R and y being angle for z). The thing is that because we are dealing with angles, we are not going to get nice simple equations because we will have cos and sin terms which muck up things. As long as you have a simple root finding algorithm (of which you can get tonnes of these for free on the internet and have a look at the pseudoversion of the algorithms if you need to write your own code for legal reasons), you will be able to do this. Since you are working with mechanical equipment, I am going to go out on a limb and say that you probably have some kind of code to do numerical routines like this but I would appreciate that you correct me if need be. So basically the first step is to expand everything out and get a system of equations for cos(x) and cos(y) or sin(x) and sin(y) [You can replace the sins with cos terms using standard trig identities] and once you get the answers then you adjust for the quadrants that the answers are in and you should get the answer. 



#7
Feb1012, 05:15 AM

P: 4,570

Also I should have pointed this out above, but didn't.
With the above approach you don't need to do any crossproduct operations. The Matrix RbRc = R contains all the information for rotating x into y. We don't have to do anything else. Once you expand out the equations with your trig functions in terms of angles for b and c, then you will have to use a root finding algorithm to get your angles. After you get a solution and adjust your answers for the right coordinate, then you have your complete answer for the angles. Again, don't worry about the crossproduct: that was just the case because it was the simplest answer and it wasn't known that you needed to do it via your mechanical rotations b and c and not just get the simplest solution based on an unconstrained system. 



#8
Feb1312, 02:37 AM

P: 4

We tried the numerical approach and validated it against the CAD model. it seems to work fine. See below for the Maxima code we used. Thanks for the help.
In each iteration do: Get the signed angle between the rotatedVect and the targetvector projected on the plane with normal vector rotatdedWorkTableRotationAxis Rotate rotatedvect by angle about rotatdedWorkTableRotationAxis Get the signed angle between the rotatedVect and the targetvector projected on the plane with normal vector TiltRotationAxis Rotate rotatedvect by angle about rotatdedWorkTableRotationAxis Rotate rotatdedWorkTableRotationAxis by angle about rotatdedWorkTableRotationAxis



Register to reply 
Related Discussions  
How does NH3 have 2 rotation axes?  Chemistry  11  
Rotation of coordinate axes  Calculus & Beyond Homework  0  
align 3d object to vector by rotation  Differential Geometry  1  
Rotation of axes  Precalculus Mathematics Homework  1  
Align two Arbitrary 2D vectors  Calculus & Beyond Homework  0 