0

I am trying to implement a simple java program to draw the MandelBrot Set using JAVA fx. I understand to count the iterations of when the number exceeds the absolute bound is z = z^2 + c, where z is growing. My question is, How do i translate a complex number, eg. -2.3 + 1.8i to represent (0,0) on a canvas. i tried incrementing it by the appropriate canvas size but it did not seem to help.

Vasan
  • 4,810
  • 4
  • 20
  • 39
  • 1
    Just have the real part be x, and the imaginary be y. It's not clear what the problem here is specifically, or what you mean by "i tried incrementing it by the appropriate canvas size but it did not seem to help.". – Carcigenicate Apr 10 '18 at 17:38
  • (-2.3, 1.8) does not appear in the canvas since it starts at (0,0). I was wondering how to get the Canvas to start and render at those coordinates. – Outwitted Student Apr 10 '18 at 17:42
  • Use the standard "map range" equation. I spent a lot of time writing Mandelbrot implementations, and you'll need that equation constantly. https://rosettacode.org/wiki/Map_range#Java – Carcigenicate Apr 10 '18 at 17:44
  • This information only allows you to determine the transformation up to a factor: `x = k1 * (Real(c) + 2.3)`; `y = k2 * (Imag(c) - 1.8)` – fabian Apr 10 '18 at 17:44
  • 1
    Have a look at: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/canvas/GraphicsContext.html#setTransform-javafx.scene.transform.Affine- – mipa Apr 10 '18 at 17:45
  • No, `z` is not growing, it is dithering. When eventually `z` is known to escape to infinity, that is the number of iterations. I suggest you do some more backgroud reading. – Weather Vane Apr 10 '18 at 19:45
  • 1
    You have to *scale* the coordinates, offset from an origin, and then add to the pixel origin of the graphic you are displaying. – Weather Vane Apr 10 '18 at 19:50
  • Thanks everybody! I was able to figure it out. I took weather Vanes advice and was able to finish it. – Outwitted Student Apr 11 '18 at 21:02
  • https://en.wikibooks.org/wiki/Fractals/Computer_graphic_techniques/2D/plane – Adam May 16 '18 at 14:32

0 Answers0