If I start on a uniquely identifiable cube face and give a direction, what will the next cube face be?

46 Views Asked by At

The title might be confusing because I am having trouble summarizing this question.

Some context, I am building a device that consists of 6 OLED displays, each one representing 1 face of a cube. The aim is to have objects on the screen, able to travel seamlessly from face to face on the cube. I want to write a formula that uses 2 variables. The current face an object is on & the direction the object is heading (Up / Down / Left / Right). Using these two variables the formula should tell me what the next cube face will be.

Cube Unfolded (Roll Axis = Black, Pitch Axis = Grey, Yaw Axis = Light Grey)

When trying to solve this problem I thought the best way was to logically identify each face, by representing all the faces by their angles. Meaning all faces are represented by a unique 1x2 array for their orientation. So by increasing / decreasing Roll and Pitch by 90° I can traverse the cube.

\begin{pmatrix}Roll\\ Pitch\end{pmatrix}

Lets define ways we can move:
Up = Roll + 90°
Down = Roll - 90°
Right = Pitch + 90°
Left = Pitch - 90°

Lets make the Red face of the cube our origin (Roll = 360°, Pitch = 360°) and we want to travel to the orange face, here are some ways we could do it.

Travel Left 3 times:
Red > Purple > Yellow > Orange
Roll = 360°, Pitch = 360° - 3(90°). \begin{pmatrix}360°\\ 90°\end{pmatrix} Travel Right 1 time:
Red > Orange
Roll = 360°, Pitch = 360° + 90°. \begin{pmatrix}360°\\ 90°\end{pmatrix}

Works so far! The output array is identical whether we go left or right. Here is a visual representation:Start End (Arrow represents our orientation on the face not the direction we are headed)

Here's another example.
Travel Up 1 time & Right 1 time:
Red > Green > Orange
Roll = 360° + 90°, Pitch = 360° + 90°. \begin{pmatrix}90°\\ 90°\end{pmatrix}

Well now the method falls apart. Suddenly there are two different arrays that represent the orange face. Again a visual representation Start End

Looking at the end images, the only difference is one is rotated at a different angle on the orange face. Maybe if we added another axis of rotation, all arrays would be identical no matter how you arrived at the face.

So I assume we must use a 1x3 array, adding Yaw rotation to the equation. \begin{pmatrix}Roll\\ Pitch\\ Yaw\end{pmatrix}.

This is where I start to get lost.

If we know:
Up = Roll + 90°
Down = Roll - 90°
Left = Pitch + 90°
Right = Pitch - 90°

How does Yaw affect the values for Roll and Pitch to make sure the end result is always the same array? I feel by adding another another axis it makes the problem even harder to visualize and doesn't help.

Is it even possible or am I going about this the wrong way? Do I need to consider more than 2 variables?

Many Thanks Benjamin :)