Fractal Zooming

Hello

I'm trying to zoom into a fractal and to do this I'm using mouse click to calculate where the centre should be and then taking away 1 from the right and top and adding 1 to the left and bottom to make a zoomed in version. This works perfectly... for 15 zooms. When the value of the left and right meet eachother the fractal starts zooming out instead of in. Is there a way to get around this? Through multiplication maybe?

Thanks!

Hannah x
Last edited on
anyone?
Something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
if (myInput.mouseclick)
{
    static constexpr double DELTA = 0.1 ;
    static constexpr double EPSILON = DELTA*2 ;

    //Zoom in
    if( ( right - left ) > EPSILON )
    {
        left += DELTA ;
        right -= DELTA ;
    }

    if( ( top - bottom ) > EPSILON )
    {
        bottom += DELTA ;
        top -= DELTA ;
    }

    //Generate the zoomed in texture
    GenerateFractal(&data);
}
If you want to use multiplication, you have to define a zoom factor. It must be >= 1.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
if (myInput.mouseclick)
{
    double ShrinkFactor = 1./ZoomFactor;
    double HorizontalDelta = (1.-ShrinkFactor) * (right-left)/2;
    double VerticalDelta = (1.-ShrinkFactor) * (top-bottom)/2;

    //Zoom in
    left += HorizontalDelta ;
    right -= HorizontalDelta ;
    bottom += VerticalDelta ;
    top -= VerticalDelta ;

    //Generate the zoomed in texture
    GenerateFractal(&data);
}
Topic archived. No new replies allowed.