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 {:D :D :D |