Ok some color theory of my own:
First of all there are 3 dimensions so to speak:
The Red, The Green and The Blue.
And thus this basic color space is a cube.
And cube's have 4 points on the bottom and 4 points on the top.
So with a cube it's possible to have 8 totally different colors ?
The number of instruction is about 19 or so...
So I guess getting a good color spread is maybe trying to transform the cube
into some other kind of multi dimensional object but maybe that's a bit hard
to imagine ?
But it does give some clue's to a possible algorithm.
Hmmm... One question one could ask is: How to transform between
dimensions...
Anybody having done graphics knows how to do this:
It's quite simple:
Z * SecondDimensionSize * FirstDimensionSize + Y * FirstDimensionSize + X;
So this can simply be extrapolated to multiple dimensions.
However my base dimension is not 1D... it's actually 3D does this matter ?
No it does not... since a color is simply red, green, blue, or just an
integer.
So it's already doing these kind of transformations.
However how to best divide 19 into X dimensions ?
Hmmm...
Euh dimensions could even have their own size... but for now... let's assume
they are all equal in size.
If I want 19 distrinct colors...
Question is... how many distinct colors are there for 3 dimensions... the
answer was 8 ?
8 corners ?!
Why are there 8 corners ?
Aha !
A single dimension has 2 corners ! (Which is kinda logical... start and end)
So multi dimensions multiple the number of corners !
Therefore a cube has 8 corners:
2 * 2 * 2 = 8 corners !
So the next dimension has 16 corners ! 4D.
So the next dimension has 32 corners ! 5D.
5D will fit the 19.
But lot's of spillage going on ?
Maybe I can multiple the instruction code by something to shift it nicely
onto the corners:
Yeah.
32 corners divided by 19 = 1.6842105263157894736842105263158.
So to "map" each instruction onto it's "corner" simply multiple by that
number.
The funny thing is that the binary code actually describes the corner
coordinates in multi dimensional space ! yeah ! =D
The first bit describes the corner of the first dimension.
The second bit describes the corner of the second dimension.
The third bit describes the corner of the third dimension.
The fourth bit describes the corner of the fourth dimension.
The fith bit describes the corner of the fith dimension !
Awesome I never knew that ! super cool ! ;)
Anyway
Once I have these bits... it should become possible to simply look up the
correct value by doing:
Color[1d][2d][3d][4d][5d]
However... this could just be a lookup table of 0..31.
So now the remaining question is how to map 16 million colors to 5
dimensional space.
16 million colors is 24 bits.
the 5 bits describe the outer most corners...
Interpolating between these bits would give 0....1
So a floating point lies between them.
Now all I have to do is multiple the 5 bits... by x bits to create 24 bits.
24 bits divide by 5 bits = 4.8 "bits".
So each dimension needs to receive 4.8 bits in between.
So that's something like:
1 / 4.8 = 0.20833333333333333333
So if I simply walk across all 16 million colors...
I start with zero... and then I slow add 0.2083333 then if all goes
correctly... it should end up with 16 million colors spread across a color
space of 5D which was kinda spread across 19.
So maybe I took a detour... I already thought about this in the past in a
thread not so long ago. But I am not sure if that theory was correct... but
this once seems nice ?! and correct ?!
Ofcourse I can't walk across 16 million colors that would take ages.
I need a formula... that simply produces 19 distinct colors to start with...
It would also be nice to interpolate between them... for the modifiers...
but then I could just increase the number of distinct colors required. (by
multiplieing codecount * modifiercount)
The big question is do I now have a formula to calculate the correct 24 bit
color ?
I think so:
input can be 0, 1, 2, 3, 4, 5, 6, 7, 8 etc to 19.
This first needs to be converted to 32 by multiplieing it by the number
1.68etc.
This gives the 5 dimensional number which is 5 bits.
This is an coordinate which represents the corner of the multi dimensional
color space.
So now "we" have 5 numbers which is the coordinate:
[5d][4d][3d][2d][1d]
all are 0 or 1.
Now to understand what the 16 million/24 bit value/coordinate is we simply
had to apply the multi dimensional formula:
etc + 2d * DimensionSize * SecondDimensionSize * FirstDimensionSize + 2d
*DimensionSize +FirstDimensionSize + 1d * DimensionSize; (See below how I
came to this improvement: )
So it's quite easy to see what we have to do.
The number of bits required for each dimension was 4.8.
So the first dimension multiplier is: 2^4.8 =
27.857618025475972452360640559352
So the second dimension multiplier is: (2^4.8)^2 =
776.0468820533238181617970182689
So the third dimension multiplier is: (2^4.8)^3 =
21618.817610103099545583648296626
So the fourth dimension multiplier is: (2^4.8)^4 =
602248.76314468548964443852467231
So the fiveth dimension multiplier is: (2^4.8)^5 = 16777216
Another easier way to come to this conclusion/number is as follows:
The original color space was 3 dimensions... each dimension having a range
from 0 to 255... so that's 256 elements.
The linear dimension size is therefore: 256^3.
Now to reverse this is doing: (256^3) ^ (1/3) = ...
1/3 = 1/dimensions
So to understand what the dimension range is for 5d is simply:
^ 1/5
So to redistribute 256^3 "we" simply do:
(256^3) ^ (1/5) = 27.857618025475972452360640559352
Exactly same number which proves my theory I guess ! WIEEEEEEEEEEEEEEEE =D
So now let's see if it hold up:
Suppose the coordinate was 1,1,1,1,1
The linear value should be close to 2^24...
Which is actually proven above.... 1 to 27.857618025475972452360640559352 is
the dimension range.
So this means:
27.85, 27.85, 27.85, 27.85, 27.85
If you multiply these together you ll get 27.85^5 which is close to 2^24.
So now I have a very simply method to convert 0 to 31 to a color space of 5d
which is then mapped to 3d.
So steps are quite simple:
19 * 1.68 to convert to 5d color coordinate.
Which is 0..31...
Then extract every bit... out of those 5 bits... and covert them to the
values above...
Then perform the lineair calculation for the multipliers.
Example in 3D space:
(B * 256 * 256) + (G * 256) + R
So this would be samiliar to:
<- etc (3D * 27.8) * 27.8 * 27.8 + (2D * 27.8) * 27.8 + (1D * 27.8).
And that ladies and gentlemen concludes this Skybuck's multi-dimensional
color space theory ! ;) =D
YEAH =D
Bye,
Skybuck =D