#Need help in creating rubix cube
119 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @river sand! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
what do you mean with updated?
When i try to rotate multiple layer like once front and after right it will cause problem
Like shown above
I think its updateing issue
Oe maybe my implementation issue
you rotate the GUI but you never change the c array I think
but im java it pass by reference for array so how its not updating
or i am missing something'
are you changing it anywhere?
applying a Rotate doesn't change any position in the array
so i need to change the cordinate of cube x,y,z seprately
Do you mean swapping elements of c?
Yeah we can swap entire cube array also
if its
1 2 3
4 5 6
7 8 9
i need to
3 6 9
2 5 8
1 4 7
well it won't work if you never swap/shift the elements in the array
Like this?
why that?
every rotation would need to do that differently
that's why even having a 3D array is a problem
So list is still more suitable T-T
well you could also swap elements in the array
I think I showed you an example on how to do that
I mean its easy i just need to know adjoint side thats it
if its yellow it will be
3,4,5,6
after that i need to locate where those adjoint inner side begin
row is constant or column is constant
c[adj][2][i] this will change in red
Like this 0-0
what you think
i will very from 0 to 2
not sure what you mean with that but try it..?
Bro i found the problem
In rotate function when i was comparing value there was minor 0.00000000001 differnce and because its double it will result in false
i solved that
But now this is another issue
5 degree at a time
How, not how much
depending on user clock wise or counter clock wise
I found the problem also, all cubies have its initial position and center
Are you applying the rotate object to each box?
so when they turn for other side theri x y z axis differ than our rotation
yes
They never lose their original creation
Like if i created a cubie which have height width = 100 and depth = 0
This will cause problem
Here in yellow i am rotating x and y,,,,, z remains same there
Now in second pic i transfer one part yellow to bottom
Now if i turn bottom it will change x,z ,,,,, y remains constant
I think you should create the Rotate object before the loop
and then apply the same Rotate objects for all elements to rotate
But for all object rotation happen on different axis
and don't depend on individual cubes for calculating the rotation
liek here for yellow its z axis depened
What is the pivot?
if (c[i][j][k].m_B.getTranslateX() == -1.0) {
rotate.setPivotX(-1.25);
} else if (c[i][j][k].m_B.getTranslateX() == 0.0) {
rotate.setPivotX(0.0);
} else if (c[i][j][k].m_B.getTranslateX() == 1.0) {
rotate.setPivotX(1.25);
}
if (c[i][j][k].m_B.getTranslateY() == -1.0) {
rotate.setPivotY(-1.25);
} else if (c[i][j][k].m_B.getTranslateY() == 0.0) {
rotate.setPivotY(0.0);
} else if (c[i][j][k].m_B.getTranslateY() == 1.0) {
rotate.setPivotY(1.25);
}
this
if (c[i][j][k].m_B.getTranslateX() == -1.0) {
rotate.setPivotX(-1.25);
} else if (c[i][j][k].m_B.getTranslateX() == 0.0) {
rotate.setPivotX(0.0);
} else if (c[i][j][k].m_B.getTranslateX() == 1.0) {
rotate.setPivotX(1.25);
}
if (c[i][j][k].m_B.getTranslateY() == -1.0) {
rotate.setPivotY(-1.25);
} else if (c[i][j][k].m_B.getTranslateY() == 0.0) {
rotate.setPivotY(0.0);
} else if (c[i][j][k].m_B.getTranslateY() == 1.0) {
rotate.setPivotY(1.25);
}
this
is the pivot the rotation axis?
Shouldn't the pivot not always be the center of the cube in the middle?
like under all 9 cubes to rotate, the middle cube
You mean set it to 0 in middle?
I think..?
Can you test something?
Can you log the pivot to System.out
then do the first rotation
let me try i never tried it
and check what the pivots are?
Are the pivots the same for all 9 cubes that are rotated?
(I am talking about a "working" rotation)
X:-1.25, Y:-1.25
X:0.0, Y:-1.25
X:1.25, Y:-1.25
X:-1.25, Y:0.0
X:0.0, Y:0.0
X:1.25, Y:0.0
X:-1.25, Y:1.25
X:0.0, Y:1.25
X:1.25, Y:1.25
X:0.0, Y:-1.25
X:0.0, Y:0.0
X:0.0, Y:1.25
X:0.0, Y:-1.25
X:0.0, Y:0.0
X:0.0, Y:1.25
X:-1.25, Y:0.0
X:0.0, Y:0.0
X:1.25, Y:0.0
X:-1.25, Y:0.0
X:0.0, Y:0.0
X:1.25, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
X:0.0, Y:0.0
After one rotation it set to 0
Why this 0-0
I dont get it
Its for front layer
Total 21 cube get rotated including sides
Is that a rotation that goes wrong?
Wait pivot is always set to 0 0
yes
All pivot 0 i guess its never going in if else -_- but i guess it right'
Man i am confused
T-T
I thought you need to set pivot according to coordinates but it does nothing, with or without its same
Does it work with pivot 0?
Are you also applying any other rotate objects to the cubes?
nope not any other
At pivot 0 it seems to work fine also
So the problem occurs when the pivot is non-zero?
Maybe try that: At first, find the middle cube (meaning the one in the middle of the 9 cubes to rotate). Get the Rotate object of the middle cube. Then, apply that rotate object to all cubes you need to rotate
because I think the middle one is always correct (I hope)
Nah not at all
so?
Does it also happen with rotations where the pivot is the same for all cubes?
atually, I think a pivot of 0 0 0 should always work
Can you try that?
ok
and by 0 0 0, I mean the center of the whole rubix cube
Yeah center will be zero because each cubes mid point is -1.5,1 .5 and 2 codinates 0
Can chat gpt read this big code
or its useless
I didn't try but I guess it will probably tell you something
probably something that doesn't solve your issue
ok let me try it T-T
I cant find anything i Gues i will do it tommorow
But you helping alot budd thanks for helpiing me this much appreciate ya , without you i guess i could not have figure out what i did
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.