Welcome to Fractal Forums

Fractal Math, Chaos Theory & Research => (new) Theories & Research => Topic started by: DarkBeam on February 10, 2011, 11:31:54 AM




Title: Binary box tiling (now solved)
Post by: DarkBeam on February 10, 2011, 11:31:54 AM
 :sad1: I was wondering about a new idea for a custom mapping but code it is harder than it seems :fiery:

The idea is explained in the image... Surely I do cheap errors as always! :sad1:

(Needless to say; x=0 and y=0 in center of image. :dink: )


Title: Re: Binary box tiling (help me!)
Post by: David Makin on February 10, 2011, 06:27:09 PM
If I were you I'd work things out from the infinite limit of the top-left corner (i.e. top or left).

Assuming the coordinate system is normalised such that the height and width of the largest box is 1.0 then if the top-left (infinite limit) is taken as (0,0) then the bottom-right of the largest box is (2.0,2.0).


Title: Re: Binary box tiling (help me!)
Post by: DarkBeam on February 12, 2011, 07:59:51 PM
Thanks David. I surrended, an entire day lost trying and now I don't want to hear about this sh... never again. :fiery:


Title: Re: Binary box tiling (help me!)
Post by: David Makin on February 13, 2011, 04:52:34 AM
Assuming you follow my previous post then the size of the box that a given pixel is in is given by:

s = 2^(floor(log2(min(x,y))))

And the coordinates for the box of that size are:

u = x%s;    = mod(x,s) I think
v = y%s;    = mod(y,s)
x = x-u;
y = y-v;
u = u/s;
v = v/s;

Where the result x,y are the top-left coordinates of the required box (of side s) and u and v are the coords within the source box (of side 1.0) - just add 1.0 to u and v if the source to be used is actually the box that is at coords (1,1) to (2,2) rather than a separate input object.

Note that I'm assuming I'm correct in the above in thinking that floor(-0.5) is -1, floor(-1.75) is -2 and floor (1.5) is 1, if not then you need to change the "floor" to the correct function.
Also note that I haven't actually tested the above, I just give it as what I would try first.
Of course you'd need to adjust the algorithm or simply mirror/flip or rotate to get all 4 directions of the complete square of squares instead of just the top/left.


Title: Re: Binary box tiling (help me!)
Post by: DarkBeam on February 13, 2011, 05:34:19 PM
Maybe! But I am so sick and tired of trying that I don't want to try this ... Thanks anyway :D :embarrass:


Title: Re: Binary box tiling (help me!)
Post by: DarkBeam on February 14, 2011, 10:11:41 AM
 :worm: :worm: :worm:

I analyzed again and again the problem, and finally the solution popped out!!! ;D It was not so easy but now it works like a charm! UF version;

Code:
binarytil {
global:
  ;NOP
transform:
  complex px = @dcen+#pixel * @scale3
  float x=imag(px)
  float y=real(px)
  float LO=2^(-@startv)
  float HI = LO+LO*LO
  float k = -99
  float M = 99
  float swap = 99
  bool halt = false

   repeat      ; -----------
    M = abs(x)
    if abs(y)>M
    M = abs(y)
    endif
    if (M<HI && M>LO)
       halt = true
       if abs(x)>abs(y)
          k =  abs(x) / x
          x = (x - k * ( HI + LO ) * .5)* 2*@scale2 /( HI - LO )
          k =  abs(y) / y
          y = y* 1/( HI - LO )
          y = (y - trunc(y) - k * .5)*2*@scale2
       ; -----------
          elseif abs(y)>abs(x)
          k =  abs(y) / y
          y = (y - k * ( HI + LO ) * .5)* 2*@scale2 /( HI - LO )
          k =  abs(x) / x
          x = x* 1/( HI - LO )
          x = (x - trunc(x) - k * .5)*2*@scale2
       endif
    ; -----------
    else
    swap = LO
    LO = HI
    HI = HI + (HI-swap) * .5
    halt = (|HI-LO| <= |@cutoff| )
    endif
   until (halt)     ; -----------

  px = y+flip(x)
  #pixel = px*@scale - @dcen
default:
  title = "Binary tiling"
  complex param dcen
    caption = "Center shift"
    default = (0,0)
  endparam
  float param scale
    caption = "Outer scale"
    default = 2
  endparam
  float param scale2
    caption = "Inner scale"
    default = 1
  endparam
  float param scale3
    caption = "Overall scale"
    default = 1
  endparam
  float param cutoff
    caption = "Cutoff"
    default = 1e-20
  endparam
  int param startv
    caption = "Axiom"
    default = 0
    min = 0
    max = 8
  endparam
}

 :D :D :D