I was working on a Mandelbrot set at first, then added a Julia set to the same window. The problem is I don't know the formula for my exact situation. Also, the Julia set slid to the bottom-left side. The issue is that it's not taking into account the zoom factor and the x, y offsets, and (for some reason) only accounting the bottom left square like 50 by 100 pixels. Here's my code and formula:
fractal image with the julia set missplaced:

zx = ((mouse.x / 800.0 - 0.5) / (1 / mandelbrot.get_zoom_scale())) * 6 - mandelbrot.get_x_offset() - 3.5;
zy = ((mouse.y / 600.0 - 0.5) / (1 / mandelbrot.get_zoom_scale())) * 6 - mandelbrot.get_y_offset() - 2.5;
The constructor of the class that handles all the fractals has these parameters:
FractalBase<Derived>::FractalBase()
: max_iterations(300), basic_zoom_x(240.0f), basic_zoom_y(240.0f),
zoom_x(basic_zoom_x), zoom_y(basic_zoom_y),
x_offset(3.5f), y_offset(2.5f),
zoom_factor(1.0f), zoom_speed(0.1f),
pixels(new unsigned char[width * height * 4]), paletteSize(palette.size()),
zoom_scale(1.0f), width(400), height(300)
So, the main problem is that it miscalculates the zx and zy parameters, not including the zoom_factor, and not accounting for the offsets. I tried a lot of different functions but just couldn't find the one that will actually work. I would like assistance with the formula.
doublemath as inmouse.x / 800.0 ..., yetfloatmath elsewhere?mousevariable is justsf::Vector2i, means it contains 2 integer values representing positioning of the mouse in the window in pixels, and as you can tell, it just have 2 integer numbers inside, so if you don't cast to the flooring number one of those, it will divide incorrectlydoublewhen rest of code usesfloat? Mandelbrot's are sensitive to that sort of thing. I do not know it it makes a difference for you issue, just trying to understand why your code uses a mixture of FP types. I'd consider usingdoubleorfloateverywhere.