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

  • Thread starter kolleamm
  • Start date
349
32
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
 

berkeman

Mentor
55,306
5,495
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:
474
174
Perhaps misunderstand but have you looked up Euler angles?
 
700
202
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...
 

Filip Larsen

Gold Member
1,212
149
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.
 
349
32
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

Filip Larsen

Gold Member
1,212
149
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.
 
474
174
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:
349
32
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.
 
474
174
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!!!
 
349
32
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.
 
709
316
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?
 
474
174
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.
 
709
316
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:
474
174
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.....
 
709
316
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.?
 
474
174
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.
 
349
32
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
 
349
32
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.
 

Want to reply to this thread?

"Rotate a shape back to its original position with the fewest rotations" You must log in or register to reply here.

Related Threads for: Rotate a shape back to its original position with the fewest rotations

Replies
8
Views
2K
Replies
3
Views
3K
Replies
1
Views
2K
Replies
1
Views
6K

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top