POV-Ray : Newsgroups : povray.binaries.images : Rubix Cube : Re: Rubix Cube Server Time
3 Oct 2024 23:24:35 EDT (-0400)
  Re: Rubix Cube  
From: Spider
Date: 5 May 1999 22:04:34
Message: <3730E94D.63153DE9@bahnhof.se>
Ken wrote:
> 
> RED-Cow wrote:
> >
> > I got bored the other day and decided to make one of these.  I'm
> > wondering if Moray's Inverse Kinematics could be used to make it so the
> > sides are rotatable.  That would be cool.
> 
>   From what I understand about inverse kinematics this would probably
> be a poor application of it's abilities. All you really need to do is
> declare a group of nine cubes on one face in a union and then rotate
> it around it's own axis.
> 
>  A little random color distribution from that shown would at least
> seperate yours from the dozen or so I have seen all displayed in a
> solved state of rest.
> 
>   To get it really mixed up i.e. to make it usable is not something I
> think would be worth the effort. Might make for a really challenging
> animation project. Write a routine that randomly mixes up the cube and
> the remainder of the animation pov spends trying to solve it. Might be
> possible but way beyond anything I would like to try.
> 
>   Hey Spider ! Got a new challenge for you. <* big wide grin *>

oh, great, thanks :-)
*grins*

Well, to solve this one, I think It'd be easiest to start from a "correct" cube.
Then, using a macro to rotate the sides...

You'dd use a 3x3x3 array to specify each "row" (a square, really.) of boxes.

from one side it would be: (ascii)
+-----------+
|  0        |
+-----------+
|  1        |
+-----------+
|  2        |
+-----------+
Then, to rotate theese, youd simply(hehe, not really) write a macro that takes
in the row, and rotates this arounnd an axis. 

Either three different macros (my preferred idea) or one that takes two
values(axis and number, this is more difficult since you must decide in what
plane the square is to be found)

#declare colour_index = array[6] { //Each colour. used inside the cube array.
  colour rgb <1,1,1>,  //White, first colour
  colour rgb <1,1,0>,  //Yellow
  colour rgb <0,0,1>,  //Blue
  colour rgb <0,1,0>,  //Green
  colour rgb <1,0,0>,  //Red
  colour rbg <0,1,1>  //What's the last one? I don't have a cube.
}


//This array contains every individual "block-face" in the cube.
#declare cube = array[3][3][6] { //Number theese so that all sides have the 
				//right colours.
				//The axis are the face normals. (commented)
  {{0,0,0},{0,0,0}}, //+y
  {{1,1,1},{1,1,1}}, //-y
  {{2,2,2},{2,2,2}}, //+z
  {{3,3,3},{3,3,3}}, //-z
  {{4,4,4},{4,4,4}}, //+x
  {{5,5,5},{5,5,5}}} //-x
}

#macro rotate_y(iRow) { //rotate around the y axis. numbered from +y to -y
  #local theBox = array[3][4] { //A snip the right row. 
				//3 boxes a side, 4 sides.
//Well, I'm tired, can't figure out how to decide what row is where. 
//I'll think about it tomorrow.
//I'd guess for this:
    {cube[][][],cube[][][],cube[][][]},
    {cube[][][],cube[][][],cube[][][]},
    {cube[][][],cube[][][],cube[][][]},
    {cube[][][],cube[][][],cube[][][]}
  }
}


After some thinking, I realise this code won't really work at all.
The outer lines aren't counted for. I'll blame my tiredness..
But, yes, i think I can solve it using a few arrays and a couple of macros.
Thanx for the thought anyway, ken :-)

Then there is the small matter of interpolating the frames so it becomes a
smooth animation. the way I had in mind would have to be modified to use a clock
operator with the rotates. It won't be that easy to do it then...

perhaps if it was solved as a 3x3x3 array, where you manually numbered and
placed each cube in the original position, with correct colours on the sides.
That way a smooth rotation could be implemented fairly easy.

But, as I think you can guess, i'm pretty tired, adn I haven't started to work
with animations yet. might take a while before I start.


Well, I might solve this one yet. I'll be in touch, I hope.



-- 
//Spider    --  [ spi### [at] bahnhofse ]-[ http://www.bahnhof.se/~spider/ ]
And the meek'll inherit what they damn well please
	Get ahead, go figure, go ahead and pull the trigger
		Everything under the gun
			--"Sisters Of Mercy" -- "Under The Gun"


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.