Find rotation to align two vectors by rotation about two arbitrary axes

In summary, the axis-angle method of rotation is a way to find the angles b and c which will align a vector with the c-axis of rotation. This can be done using matrix methods or quaternion methods. Once you have found the angles you can use them to calculate the axis of rotation.
  • #1
Johan_L
4
0
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 Y-axis and the c-axis 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 c-axis 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?
 

Attachments

  • Configuration of axes.png
    Configuration of axes.png
    28.6 KB · Views: 798
Physics news on Phys.org
  • #2
Hey Johan L and welcome to the forums.

The best way I see to do this is to use the axis-angle 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
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
Johan_L said:
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?

Basically do the same thing as the above but in the context of your b and c axis.

So once you have found your vector above, you now do this in the context of your b-axis and your c-axis. 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 axis-angle formulation of the matrix (for this see: http://en.wikipedia.org/wiki/Rotation_matrix#Conversion_from_and_to_axis-angle)

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
We have gotten about that far. y=Rb.Rc.x
  • Where x and y are known, the vector to align and the targetvector
  • Rb is a matrix with only the angle b unknown, the axis of rotation is known
  • Rc is a matrix with only the angle c unknown, the axis of rotation is known

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
Johan_L said:
We have gotten about that far. y=Rb.Rc.x
  • Where x and y are known, the vector to align and the targetvector
  • Rb is a matrix with only the angle b unknown, the axis of rotation is known
  • Rc is a matrix with only the angle c unknown, the axis of rotation is known

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.

Basically you have to expand the equations and at some point use a numerical solution.

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 pseudo-version 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
Also I should have pointed this out above, but didn't.

With the above approach you don't need to do any cross-product 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 co-ordinate, then you have your complete answer for the angles.

Again, don't worry about the cross-product: 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
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
Code:
c:0$
b:0$
cStep:0$
bStep:0$
rotatedVect:VectorInTableCoordinates$
rotatdedWorkTableRotationAxis:WorkTableRotationAxis$
for i:1 while i<=6 do
(
    cStep:0,
    bStep:0,
    cStep:GetRotationAngleTo(rotatedVect,TargetVector,rotatdedWorkTableRotationAxis),
    c:c+cStep,
    
    rotatedVect:Rotate(rotatedVect,cStep,rotatdedWorkTableRotationAxis),
    bStep:GetRotationAngleTo(rotatedVect,TargetVector,TiltRotationAxis),
    b:b+bStep,
    
    rotatedVect:Rotate(rotatedVect,bStep,TiltRotationAxis),
    rotatdedWorkTableRotationAxis:Rotate(rotatdedWorkTableRotationAxis,bStep,TiltRotationAxis),
    print(iteration+ i),
    print(b/deg),
    print(c/deg)
    
);
c/deg;
b/deg;
 

1. How do you find the rotation to align two vectors?

The rotation needed to align two vectors can be found by using the cross product and dot product of the two vectors. The cross product will give the axis of rotation, and the dot product will give the angle of rotation.

2. Can you explain the concept of "rotation about two arbitrary axes"?

Rotation about two arbitrary axes means that the rotation is not limited to just one axis, but can occur around any two axes in three-dimensional space.

3. What is the difference between rotation and translation?

Rotation refers to the movement of an object around a fixed point or axis, while translation refers to the movement of an object from one position to another without any rotation.

4. How do you use matrices to find the rotation to align two vectors?

Matrices can be used to represent rotations in three-dimensional space. By multiplying the rotation matrices of the two vectors, the resulting matrix will give the rotation needed to align the vectors.

5. Can the rotation to align two vectors be uniquely determined?

Yes, the rotation to align two vectors can be uniquely determined if the two vectors are not parallel and have a non-zero length. This is because the cross product and dot product will result in a unique axis and angle of rotation.

Similar threads

  • Linear and Abstract Algebra
Replies
4
Views
1K
  • Linear and Abstract Algebra
Replies
9
Views
380
  • Linear and Abstract Algebra
Replies
8
Views
2K
  • Linear and Abstract Algebra
Replies
4
Views
934
  • Linear and Abstract Algebra
Replies
6
Views
1K
  • Mechanical Engineering
Replies
3
Views
365
  • Linear and Abstract Algebra
Replies
7
Views
2K
  • Linear and Abstract Algebra
Replies
3
Views
184
Replies
12
Views
901
Replies
31
Views
2K
Back
Top