Calculating the starting size of a length, when it grows per iteration and must remain within a limit

StackOverflow https://stackoverflow.com/questions/18753582

문제

Ok so, obviously from the way I've worded my question; I'm no mathematician. I'm currently experimenting with fractals, and this specific question refers to the 'TSqare' fractal. (See bottom of question for explanation).

Basically I want to calculate the size of the initial square, so the resulting fractal of depth(n) never extends beyond the limit of the drawing surface. I've tried to figure it out myself, but I'm getting no where.

All I have figured out is the rate the square grows:

Assuming an initial size of 100, total length of fractal is as follows
Depth(0) = 100
Depth(1) = 150
Depth(2) = 175

Unfortunately I can't even figure out the formula for that, even though the pattern is obvious. D:

length = originalLength + (originalLength / 2 ^ depth)

So I've bubbled this down to algebra, assuming the drawing surface is 512 * 512, and the current depth is 2. The formula is as follows:

x + (x / 22) = 512

Then all I need to do is solve for x right to get the initial size for depth size 2?




TSquare Definition: An initial square S0 is drawn with size x2. Each iteration 4 Squares half the size of the original (x2/2) are drawn with their centers on the 4 vertices of the square before it. See http://www.smokycogs.com/blog/t-square-fractals/ for more details.

도움이 되었습니까?

해결책

If you want to get the original length for any depth, where the max size equals the originalLength + (originalLength / 2 ^ depth), you can set up the equation m = x + (x/2^d). Solving this for x, you get x = m * 2^d/(2^d + 1) for any d, where d equals the depth, x equals the initial size, and m equals the maximum size (512 in your case). So, for your question of what's the initial size if the depth equals 2 and the max size = 512, the initial size is 409.6.

For future reference, a better place to ask this probably would've been https://math.stackexchange.com/. (Since this question's a little more about math and equations that programming).

HTH

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top