Rotate a shape back to its original position with the fewest rotations

In summary, the conversation discusses the problem of rotating a shape back to its original position with the least amount of rotations. This involves a cube with starting rotation at (0,0,0) and the ability to rotate on each axis (x,y,z) by 90 or -90 degrees. The method/algorithm for determining the minimum number of movements required to return the shape to its original rotation is discussed, with the suggestion of using Euler angles and rotation matrices. The conversation also touches on the difficulties of simultaneously rotating all axes towards a desired position and the concept of noncommutivity in rotations. Finally, a possible solution is proposed which involves iterating through all possible combinations of rotations to find the closest match.
  • #1
kolleamm
477
44
TL;DR Summary
Rotate a shape back to it's original position with the least amount of rotations.
Summary: Rotate a shape back to it's original position with the least amount of rotations.

Lets say you have a cube. It's starting rotation is (0,0,0).
It can be rotated on each axis ( x,y,z ) no more than once each by 90 or -90 degrees
(rotation can also be skipped for any axis).

The shape has been rotated and the movements are unknown (its new rotation is known).
What method/algorithm could be used to determine the least amount of movements required to put it back to it's original rotation (0,0,0)?
(multiple solutions are allowed)
Rotations must happen sequentially.

My best guess is iterating through each possibility, but there has to be a better solution. This is related to animation.

Thanks in advance
 
Physics news on Phys.org
  • #2
If the rotations are limited to 90 degrees, it seems like the (worst case) minimum number would be 2 + 2 +2 = 6.

EDIT -- added "worst case" parenthetical comment
 
Last edited:
  • Like
Likes sysprog
  • #3
Perhaps misunderstand but have you looked up Euler angles?
 
  • Like
Likes Nik_2213
  • #4
If you know which way it faces now, and which way it must face, surely you only need one (1) compound rotation, twirling it non-orthogonally ??

Matrix math makes it trivial, but I remember doing this using XYZ light-years and compound angle formulae for a 3D Astronomy program in FP BASIC on an Apple ][+. The poor little 6502 CPU was totally maxed out: Even compiling the program made scant difference...
 
  • Like
Likes sysprog
  • #5
Maybe I misunderstand what you aim for, but if you are talking about combining a series of free rotations of a solid object in 3D space into a single rotation around a single axis, then this is always possible as per Eulers rotation theorem.

If you are new to rotations and are looking for a practical way to combine a sequence I will suggest you look at rotation matrices, as they are conceptually very easy to work with. Using these, any rotation around any axis can be written up as a 3x3 matrix and a sequence of such rotations is then represented by the 3x3 you get by multiplying all these matrices together. Note that order of multiplaction is important. Once you have the combined rotation matrix you can then convert it back to a single axis and angle.
 
  • Like
Likes sysprog, kolleamm and Nik_2213
  • #6
Thank you all for your response.
Basically my problem is that I have a robotic arm and each axes of rotation is controlled by a motor.
I have no idea how to convert Euler angle rotational data to rotational instructions for each motor.

Please see the image.
 

Attachments

  • FullSizeR(29).jpg
    FullSizeR(29).jpg
    29.7 KB · Views: 276
  • #7
kolleamm said:
I have no idea how to convert Euler angle rotational data to rotational instructions for each motor.

You may want to research the topic of forward kinematics. All my textbooks (and knowledge) on robotics are age old so I do not have any online reference on the topic. Perhaps others know of a good reference?

Also, if you are to provide command instructions to an actual robotic arm (as opposed to "just" doing the math part), then you obviously also need to research a lot of other topics.
 
  • #8
The first thing you need to do is use a standard right-handed coordinate system!
If you can do matrices then you should take the trouble to understand Euler rotations. You know that the fundamental problem is that these operations are non commuting (i.e the order of operations matters). There are a variety of ways to approach this problem and the best solution depends upon the entire system. To solve your original question is a textbook exercise.

Edit: Please ignore the first sentence (I got snared in an optical illusion)
 
Last edited:
  • Like
Likes sysprog
  • #9
What if I want to simulatenously rotate all axes towards this position? I've been thinking about this for a while, I really can't seem to find a solution. You adjust one axes and it just screws up the other.
 
  • #10
kolleamm said:
What if I want to simulatenously rotate all axes towards this position? I've been thinking about this for a while, I really can't seem to find a solution. You adjust one axes and it just screws up the other.
Welcome to noncommutivity.
Presumably you have an algorithm to go from some known position to where you want to be? If so you can always exactly reverse it.
Other than the motors do you have feedback about the orientation?

Look up infinitesimal rotations and see if it gives you any ideas. You won't figure this out strictly by fiddling. The Euler prescription always does finite rotations in a given sequence. There is nothing easier for the general case. Maybe your specific requirements are less general but you give no indication. This is not a trivial problem!
 
  • Like
Likes sysprog
  • #11
hutchphd said:
Welcome to noncommutivity.
Presumably you have an algorithm to go from some known position to where you want to be? If so you can always exactly reverse it.
Other than the motors do you have feedback about the orientation?

Look up infinitesimal rotations and see if it gives you any ideas. You won't figure this out strictly by fiddling. The Euler prescription always does finite rotations in a given sequence. There is nothing easier for the general case. Maybe your specific requirements are less general but you give no indication. This is not a trivial problem!
Currently the only information I have is two 3d vectors, and their Euler angle rotations.
I did look up infinitesimal rotations
and if I understand correct it attempts to use matrices to solve a transformation?

I did come up with a possible solution in the meantime. Assuming each axis can only have 360 degrees max and there are 3 axes, I could quite simply iterate through all the possible combinations to find the most matching 3d matrix.
(0,0,0) ; (0,0,1) ; (0,0,2) ... (360,360,359) ; (360,360,360);

360 x 360 x 360 = 46,656,000 combinations which a computer could solve and find the closest matching one.
 
  • Haha
Likes sysprog
  • #13
kolleamm said:
Currently the only information I have is two 3d vectors, and their Euler angle rotations.
I did look up infinitesimal rotations
and if I understand correct it attempts to use matrices to solve a transformation?

I did come up with a possible solution in the meantime. Assuming each axis can only have 360 degrees max and there are 3 axes, I could quite simply iterate through all the possible combinations to find the most matching 3d matrix.
(0,0,0) ; (0,0,1) ; (0,0,2) ... (360,360,359) ; (360,360,360);

360 x 360 x 360 = 46,656,000 combinations which a computer could solve and find the closest matching one.
Why 359 instead of 360?
 
  • #14
Look this is not that hard.

I'm confused by the drawing. You have two sets of coordinates labelled identically the same. Put primes on the object axes!

How does motor 3 differ from motor 2 ? If motor 3 rotates about y' then this problem is nearly trivial using Euler's angles.
 
  • Like
Likes sysprog
  • #15
hutchphd said:
Look this is not that hard.

I'm confused by the drawing. You have two sets of coordinates labelled identically the same. Put primes on the object axes!

How does motor 3 differ from motor 2 ? If motor 3 rotates about y' then this problem is nearly trivial using Euler's angles.
What about time?
 
Last edited:
  • #16
sysprog said:
What about time?
I seems like you would need to do them sequentially. But that can't be true...the end point has to be unique. I think the motors just spin to the calculated angle however they want...
 
  • Like
Likes sysprog
  • #17
hutchphd said:
I seems like you would need to do them sequentially. But that can't be true...the end point has to be unique. I think the motors just spin to the calculated angle however they want...
Please let us remember stepping motors -- discrete, continuous, etc.?
 
  • #18
Actually the sequencing is subtle. I think motor 3 would have to be connected to motor 2 which is connected motor 1 which is connected to the lab for Euler to be exact. I don't think the motor matters so long as it rotates under control.
 
  • Like
Likes sysprog
  • #19
hutchphd said:
Look this is not that hard.

I'm confused by the drawing. You have two sets of coordinates labelled identically the same. Put primes on the object axes!

How does motor 3 differ from motor 2 ? If motor 3 rotates about y' then this problem is nearly trivial using Euler's angles.
You were right, that was a drawing mistake I put the motor on the wrong axis
 
  • #20
The motors are servo motors in this case.
I was able to solve the problem after all. I will explain it below.

Short answer -- you assign each axis a plane (front,side, top), then you align one visible axes at a time with a matching axis on the other vector from these viewpoints.

Long answer --

1.You have two 3D vectors, one for the starting rotation (start vectors)
and the other for the next rotation (next vectors).

2.You take the start vectors and align them with the global vectors so it's now straight on every world axis.

3.You establish 3 world planes, front,side,and top, and assign the appropriate x,y,z axes to each one.

4.You look at the "next vectors" from each global plane, if it's vector(assigned for that plane) is visible with a length greater than 0 you rotate it such that that vector lines up with the same axis vector on the start vector.

5.Repeat for all other planes and keep track of the 3 angles that you rotated the next vectors by.I tested this out and it works really nicely. It did take several hours of coding but it does work.
 
  • #21
kolleamm said:
Thank you all for your response.
Basically my problem is that I have a robotic arm and each axes of rotation is controlled by a motor.
I have no idea how to convert Euler angle rotational data to rotational instructions for each motor.

Please see the image.
I am going to try to answer your original question - as I understood it. It sounded as though only 90-degree rotations were allowed.
Using a rotation matrix, I will call the home position of your cube: (1,0,0; 0,1,0; 0,0,1)
A count of all possible rotations can be calculated by noting that:
-- the first row of the rotation matrix for any cube position can be any of six values: 1,0,0; -1,0,0; 0,1,0; 0,-1,0; 0,0,1; and 0,0,-1.
-- for any given first row, the second row has a choice of two positions that can be non-zero, the tow that were left as zero in the first row; and that none zero value can be either +1 or -1. So there will always be four choices.
-- once the first two rows are specified, the third row will be non-zero in the only only column that remains zero; and its value will be plus or minus one. But only one of those two choices will work - the other will produce a mirror image of the cube that cannot be corrected by rotations.

So the total number of positions is 6x4 = 24

There are six possible rotations: x, y, or z - each in either of two directions.

When these six rotations are applied to the original cube position, six unique positions are generated. So with 0 or 1 rotation, the total number of unique positions is 7.
When those six rotations are applied to those 6 new positions, an additional 11 unique positions are discovered - totaling 18.
When those six rotations are applied to those 11 new positions, an additional 6 unique positions are discovered - totaling 24.

Thus, as many as three rotations are required to correct some cube positions.
The positions that require 3 rotations are:

#19
0 0 1
0 -1 0
1 0 0

#20
0 0 -1
0 -1 0
-1 0 0

#21
0 1 0
1 0 0
0 0 -1

#22
0 -1 0
-1 0 0
0 0 -1

#23
-1 0 0
0 0 -1
0 -1 0

#24
-1 0 0
0 0 1
0 1 0
 
  • #22
I just noticed: this thread is about 8 weeks old.
I don't know how it got my attention.
 

1. How do you determine the minimum number of rotations needed to return a shape to its original position?

To determine the minimum number of rotations needed, you must first understand the symmetry of the shape. For example, a square has four rotational symmetries, meaning it can be rotated 90, 180, 270, or 360 degrees and still look the same. So, to return a square to its original position, you would only need to rotate it 90 degrees. However, a shape with less symmetry, such as a pentagon, may require more rotations to return to its original position.

2. Can any shape be rotated back to its original position with only one rotation?

No, not all shapes can be rotated back to their original position with only one rotation. As mentioned before, the amount of symmetry a shape has will determine the minimum number of rotations needed. Some shapes, like circles, have infinite rotational symmetry, meaning they can be rotated an infinite number of times and still look the same.

3. Is there a specific method or formula for determining the minimum number of rotations needed?

Yes, there are various methods and formulas that can be used to determine the minimum number of rotations needed to return a shape to its original position. One common method is to use the concept of rotational symmetry, as mentioned before. Another method is to use matrices and linear algebra to calculate the necessary rotations.

4. Are there any real-world applications for understanding how to rotate a shape back to its original position?

Yes, there are many real-world applications for understanding how to rotate a shape back to its original position. For example, in computer graphics and animation, shapes are often rotated and translated to create different visual effects. Understanding how to rotate a shape back to its original position can help ensure that the desired visual effect is achieved.

5. Are there any shortcuts or tricks for rotating a shape back to its original position with the fewest rotations?

Yes, there are some shortcuts and tricks that can be used to rotate a shape back to its original position with the fewest rotations. One trick is to identify any rotational symmetries the shape may have and use those rotations to return it to its original position. Another shortcut is to use a combination of rotations and translations, which can sometimes be more efficient than just rotations alone.

Similar threads

Replies
2
Views
2K
Replies
2
Views
981
  • Linear and Abstract Algebra
Replies
15
Views
3K
Replies
2
Views
133
  • Programming and Computer Science
Replies
1
Views
1K
  • Linear and Abstract Algebra
Replies
1
Views
2K
  • Classical Physics
Replies
5
Views
1K
Replies
2
Views
1K
  • Introductory Physics Homework Help
Replies
9
Views
1K
Replies
3
Views
1K
Back
Top