#Need help in creating rubix cube

119 messages · Page 1 of 1 (latest)

river sand
#

So i have pretty much created everything in rubix cube and rotation!

only problem is my Cube is not getting updated after i rotate it how i can achieve it please need help

whole islandBOT
#

This post has been reserved for your question.

Hey @river sand! Please use /close or the Close Post button 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.

winter island
#

what do you mean with updated?

river sand
#

Like shown above

#

I think its updateing issue
Oe maybe my implementation issue

winter island
#

you rotate the GUI but you never change the c array I think

river sand
#

or i am missing something'

winter island
#

applying a Rotate doesn't change any position in the array

river sand
#

so i need to change the cordinate of cube x,y,z seprately

winter island
#

Do you mean swapping elements of c?

river sand
#

if its
1 2 3
4 5 6
7 8 9

i need to

3 6 9
2 5 8
1 4 7

winter island
#

well it won't work if you never swap/shift the elements in the array

river sand
#

Like this?

winter island
#

every rotation would need to do that differently

#

that's why even having a 3D array is a problem

river sand
winter island
#

well you could also swap elements in the array

#

I think I showed you an example on how to do that

river sand
#

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

winter island
#

not sure what you mean with that but try it..?

river sand
#

see this

#

I hope you will get it 0-0

#

I cant send image

#

:[

river sand
#

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

winter island
#

I kinda feared that would happen

#

How are you applying the rotation?

river sand
winter island
#

How, not how much

river sand
#

depending on user clock wise or counter clock wise

river sand
winter island
#

Are you applying the rotate object to each box?

river sand
#

so when they turn for other side theri x y z axis differ than our rotation

river sand
#

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

winter island
#

I think you should create the Rotate object before the loop

#

and then apply the same Rotate objects for all elements to rotate

river sand
winter island
#

and don't depend on individual cubes for calculating the rotation

river sand
#

liek here for yellow its z axis depened

winter island
#

What is the pivot?

river sand
#

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

winter island
#

Yes but what does it do?

#

I don't know how exactly Rotate objects work

whole islandBOT
#
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
winter island
#

is the pivot the rotation axis?

river sand
#

rotate.setAxis(Rotate.Z_AXIS);

#

this we set the axis first

winter island
#

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

river sand
winter island
#

Can you test something?

#

Can you log the pivot to System.out

#

then do the first rotation

river sand
#

let me try i never tried it

winter island
#

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)

river sand
#

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

river sand
winter island
#

Why are these 21 pivots per message?

#

shouldn't it be 9?

winter island
river sand
winter island
#

You mean for all layers?

river sand
#

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

winter island
#

Does it work with pivot 0?

#

Are you also applying any other rotate objects to the cubes?

river sand
#

At pivot 0 it seems to work fine also

winter island
#

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)

river sand
winter island
river sand
#

that is happening still

winter island
#

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?

river sand
winter island
#

and by 0 0 0, I mean the center of the whole rubix cube

river sand
#

Can chat gpt read this big code

#

or its useless

winter island
#

I didn't try but I guess it will probably tell you something

#

probably something that doesn't solve your issue

river sand
#

ok let me try it T-T

river sand
river sand
whole islandBOT