Its kind of hard to explain whats wrong with my program so ive made a video to visually show you https://youtu.be/j8yrB2BQUrI
As the video shows the rotations which involve y and z axis rotations do not work properly. Ive added the code below and im aware ive added a lot of it so sorry.
The rotateX/Y/Z functions simply update the rotation struct for each individual cube and thats it so i havent added that code in. Sorry for the poorly written question ive just tried everything i can think of and cant get it to work
`
private async void L(int n) //This is a working function
{
for (int i = 0; i < 15 * n; i++)
{
cube[0].rotateX(6 *DEGREE);
cube[1].rotateX(6 * DEGREE); //rotates the left face of the cube 90 degrees
cube[2].rotateX(6 * DEGREE);
cube[9].rotateX(6 * DEGREE);
cube[10].rotateX(6 * DEGREE);
cube[11].rotateX(6 * DEGREE);
cube[17].rotateX(6 * DEGREE);
cube[18].rotateX(6 * DEGREE);
cube[19].rotateX(6 * DEGREE);
Invalidate(rec);
await Task.Delay(1);
}
cube[0].rotateX(-90 * DEGREE); // here it quickly rotates the cube back to how it was originally
cube[1].rotateX(-90 * DEGREE);
cube[2].rotateX(-90 * DEGREE);
cube[9].rotateX(-90 * DEGREE);
cube[10].rotateX(-90 * DEGREE);
cube[11].rotateX(-90 * DEGREE);
cube[17].rotateX(-90 * DEGREE);
cube[18].rotateX(-90 * DEGREE);
cube[19].rotateX(-90 * DEGREE);
CubeFaces = Rotations.L(1, CubeFaces); // this changes the colours of the left face and then updates the display
Invalidate(rec); // to make it seem as if the cube has rotated
}
private async void R(int n) // this is also a working function
{
for (int i = 0; i < 15 * n; i++)
{
cube[6].rotateX(-6 * DEGREE);
cube[7].rotateX(-6 * DEGREE);
cube[8].rotateX(-6 * DEGREE);
cube[14].rotateX(-6 * DEGREE);
cube[15].rotateX(-6 * DEGREE);
cube[16].rotateX(-6 * DEGREE);
cube[23].rotateX(-6 * DEGREE);
cube[24].rotateX(-6 * DEGREE);
cube[25].rotateX(-6 * DEGREE);
await Task.Delay(1);
Invalidate(rec);
}
cube[6].rotateX(90 * DEGREE);
cube[7].rotateX(90 * DEGREE);
cube[8].rotateX(90 * DEGREE);
cube[14].rotateX(90 * DEGREE);
cube[15].rotateX(90 * DEGREE);
cube[16].rotateX(90 * DEGREE);
cube[23].rotateX(90 * DEGREE);
cube[24].rotateX(90 * DEGREE);
cube[25].rotateX(90 * DEGREE);
CubeFaces = Rotations.R(1, CubeFaces);
Invalidate(rec);
}
private async void U(int n) // this function does not work. you will see why when i run it
{
for (int i = 0; i < 15 * n; i++)
{
cube[0].rotateY(6 * DEGREE);
cube[3].rotateY(6 * DEGREE);
cube[6].rotateY(6 * DEGREE);
cube[9].rotateY(6 * DEGREE);
cube[12].rotateY(6 * DEGREE);
cube[14].rotateY(6 * DEGREE);
cube[17].rotateY(6 * DEGREE);
cube[20].rotateY(6 * DEGREE);
cube[23].rotateY(6 * DEGREE);
//cube[0].rotateX(cube[0].GetRotation().z);
//cube[3].rotateX(-rotation.x);
//cube[6].rotateX(-rotation.x);
//cube[9].rotateX(-rotation.x);
//cube[12].rotateX(-rotation.x);
//cube[14].rotateX(-rotation.x);
//cube[17].rotateX(-rotation.x);
//cube[20].rotateX(-rotation.x);
//cube[23].rotateX(-rotation.x);
await Task.Delay(1);
Invalidate();
}
}
private async void F(int n) // this also doesnt work and you will see why when i run it
{
for (int i = 0; i < 15 * n; i++)
{
cube[0].rotateZ(6 * DEGREE); // so the x axis rotations work however the y and z do not
cube[1].rotateZ(6 * DEGREE);
cube[2].rotateZ(6 * DEGREE);
cube[3].rotateZ(6 * DEGREE);
cube[4].rotateZ(6 * DEGREE);
cube[5].rotateZ(6 * DEGREE);
cube[6].rotateZ(6 * DEGREE);
cube[7].rotateZ(6 * DEGREE);
cube[8].rotateZ(6 * DEGREE);
await Task.Delay(1);
Invalidate();
}
//cube[0].rotateZ(-90 * DEGREE);
//cube[1].rotateZ(-90 * DEGREE);
//cube[2].rotateZ(-90 * DEGREE);
//cube[3].rotateZ(-90 * DEGREE);
//cube[4].rotateZ(-90 * DEGREE);
//cube[5].rotateZ(-90 * DEGREE);
//cube[6].rotateZ(-90 * DEGREE);
//cube[7].rotateZ(-90 * DEGREE);
//cube[8].rotateZ(-90 * DEGREE);
//CubeFaces = Rotations.F(1, CubeFaces);
}
`
i tried to do what is commented out in the U function and i was thinking it could counteract the cube rotating in its weird ways but it just made it worse