3D buddhabrot cloudpoint (fortran code)

  • 12 Replies
  • 268 Views

0 Members and 1 Guest are viewing this topic.

Offline ker2x

  • *
  • Fractal Fanatic
  • ***
  • Posts: 21
« on: September 12, 2019, 08:14:48 PM »
i just rushed this or i wouldn't be able to sleep.
it's generate a 3D buddhabrot (i call it "flowabrot") and write it in xyz format that can be read with pretty much any cloudpoint viewer (i use ccviewer from http://www.danielgm.net/cc/ )
The code is ugly, the result is ugly, it need to be improved in every way but it works.



Code: [Select]
PROGRAM VOXELFLOWABROT

    IMPLICIT NONE
   
    CHARACTER ( len = 255 ), PARAMETER :: filename = 'flowa.xyz'
    INTEGER, PARAMETER :: file_out_unit = 10
   
    INTEGER, PARAMETER :: miniter = 20
    INTEGER, PARAMETER :: maxiter = 2000
    INTEGER, PARAMETER :: batchsize = 10000000
    INTEGER*8 :: i = 1, j=1
    INTEGER :: iter = 0
   
    REAL :: pts_x(maxiter+1)
    REAL :: pts_y(maxiter+1)
    REAL :: pts_z(maxiter+1)
   
   
    REAL :: xmin = -1.0, xmax = 2.0, ymin = -1.3, ymax =1.3
    REAL :: x=0 ,y=0 ,z=0 ,nx=0 ,ny=0 ,nz=0 ,r=0 ,r2p=0 ,th=0 ,ph=0 , p=2
   
    open ( unit = file_out_unit, file = filename, status = 'replace', &
       form = 'formatted', access = 'sequential')
   
    DO i=1, batchsize
   
        CALL RANDOM_NUMBER(x)
        CALL RANDOM_NUMBER(y)
        CALL RANDOM_NUMBER(z)
        pts_x = 0
        pts_y = 0
        pts_z = 0
       
        x = (x * 2.6) - 1.3
        y = (y * 2.6) - 1.3
        z = (z * 2.6) - 1.3
        iter = 0
        nx = x
        ny = y
        nz = z
        r=sqrt(x*x+y*y+z*z)
        th=atan(y/x)*p
        ph=asin(z/r)*p
       
        DO WHILE((iter < MAXITER) .AND. (r < 2.0) .AND. (nx /= 0.0) .AND. (r /= 0.0) .AND. (nx /= -0.0) .AND. (r /= -0.0))
       
            r2p = r*r
            th=atan(ny/nx)*p
            ph=asin(nz/r)*p
            nx=r2p*cos(ph)*cos(th)+x
            ny=r2p*cos(ph)*sin(th)+y
            nz=r2p*sin(ph)+z
       
            pts_x(iter) = nx
            pts_y(iter) = ny
            pts_z(iter) = nz
            r=sqrt(nx*nx+ny*ny+nz*nz)
            iter = iter +1
       
        END DO

        if((r > 2.0) .AND. (iter > miniter)) THEN
           
            DO j=miniter, iter -1 , 1
                !print *, pts_x(j), pts_y(j), pts_z(j)
                write ( file_out_unit, '(f9.5,f9.5,f9.5)' ), pts_x(j), pts_y(j), pts_z(j)
            END DO
       
        END IF
   
    END DO
    close ( unit = file_out_unit )

END




Linkback: https://fractalforums.org/programming/11/3d-buddhabrot-cloudpoint-fortran-code/3072/

Offline ker2x

  • *
  • Fractal Fanatic
  • ***
  • Posts: 21
« Reply #1 on: September 12, 2019, 08:22:33 PM »
an antiflowabrot (just invert the > 2.0 condition)


Offline Fraktalist

  • *
  • Administrator
  • *******
  • Strange Attractor
  • Posts: 1142
« Reply #2 on: September 12, 2019, 09:40:26 PM »
uh, I really like the idea. excited to see more.  :yes:

Offline gerson

  • *
  • Fractal Furball
  • ***
  • Posts: 225
« Reply #3 on: September 12, 2019, 10:30:40 PM »
waiting too, seems to be a special work, some kind of fluid.

Offline ker2x

  • *
  • Fractal Fanatic
  • ***
  • Posts: 21
« Reply #4 on: September 12, 2019, 11:22:43 PM »
Fortran is so cool, you can just write whatever come to your mind and it works.

Offline gerson

  • *
  • Fractal Furball
  • ***
  • Posts: 225
« Reply #5 on: September 13, 2019, 12:19:35 AM »

Offline Fraktalist

  • *
  • Administrator
  • *******
  • Strange Attractor
  • Posts: 1142
« Reply #6 on: September 13, 2019, 03:02:16 AM »
why post a still picture if you can interact with it? ;)
http://haxiomic.github.io/GPU-Fluid-Experiments/html5/?q=UltraHigh

Offline gerson

  • *
  • Fractal Furball
  • ***
  • Posts: 225
« Reply #7 on: September 13, 2019, 04:18:31 PM »
@ Fraktalist - just to do some marketing of my gallery  ;D
if you want to play see too
http://oliverbcurtis.co.uk/FluidDynamics2/bin/web/

@ ker2x very good job, keep doing and show us what you are doing.
is it just screen size or is possible to render it at any size?
what part of the code is the color programing?

Offline ker2x

  • *
  • Fractal Fanatic
  • ***
  • Posts: 21
« Reply #8 on: September 14, 2019, 08:15:48 PM »


i bought a cheap laptop to develop in my bed, and made a new version too.
Remember, this is a pointcloud, so you can freely rotate the view with a pointcloud viewer. (or generate mesh, or stereo, or VR, whatever your viewer can do)
My code simply generate a .xyz file (for now, it's the easiest and most compatible, but since its ascii file the file are absurdly large, the file for the image above is 108MB and the program ran for less than a minute)

now that i refactored the code, and included a GUI, i can add more feature (mostly filtering outliers and duplicate)

Offline ker2x

  • *
  • Fractal Fanatic
  • ***
  • Posts: 21
« Reply #9 on: September 14, 2019, 08:20:33 PM »
@ Fraktalist - just to do some marketing of my gallery  ;D
if you want to play see too
http://oliverbcurtis.co.uk/FluidDynamics2/bin/web/

@ ker2x very good job, keep doing and show us what you are doing.
is it just screen size or is possible to render it at any size?
what part of the code is the color programing?

there is no color programing yet. i can do it (eg : based on the coordinate of the 1st iteration).
The main problem is because my output is in xyz format and anything beside x,y,z position are non-standard.
Since i know that i can easily add color, and switching to another format is a bit of a pain right now (i will do it for sure), it's monochrome for now.
keeping the xyz format help me for debugging since it's just good old ascii data.


Offline ker2x

  • *
  • Fractal Fanatic
  • ***
  • Posts: 21
« Reply #10 on: September 17, 2019, 07:54:49 AM »
now in color and some degree of parallelism.



the xyz output was only tested with ccviewer. because of the color, it may or may not works with other cloudpoint viewer, dunno.
i started to work on a binary file output (smaller) but for now it's only its own internal format.
i'll have to choose a "standard" binary output later, dunno which one. the e57 format seems the most standard but a bit of a pain to handle in fortran.

i have some bug to fix too, and improve parallelism.

Offline ker2x

  • *
  • Fractal Fanatic
  • ***
  • Posts: 21
« Reply #11 on: September 18, 2019, 07:53:44 AM »
i just finished the implementation of the sorting algorithm.
next step is A LOT OF CODE CLEANUP (because it's in a terrible state...), then filtering (remove (near)duplicate is the first step, that's why i needed sorting).



eww...

Offline gerson

  • *
  • Fractal Furball
  • ***
  • Posts: 225
« Reply #12 on: September 20, 2019, 05:36:02 PM »
Both are good, first ones and this with color. Interesting images.


xx
Buddhabrot Mag(nifier) - A realtime buddhabrot zoomer

Started by Sharkigator on Other

15 Replies
1825 Views
Last post December 23, 2017, 08:00:35 PM
by Fraktalist
xx
fortran tutorial, Q&A

Started by ker2x on Programming

0 Replies
41 Views
Last post September 15, 2019, 10:56:42 AM
by ker2x
xx
Buddhabrot

Started by FractalStefan on Image Threads

3 Replies
442 Views
Last post February 26, 2018, 11:28:21 PM
by FractalStefan
xx
Buddhabrot

Started by Bill Snowzell on Fractal Image Gallery

0 Replies
254 Views
Last post October 12, 2017, 09:53:06 PM
by Bill Snowzell
xx
Buddhabrot Angel

Started by Sharkigator on Fractal Image Gallery

3 Replies
250 Views
Last post August 30, 2018, 05:56:00 PM
by tavis