From da56a6d0c02bf9d3e442df3a07c9219fed526070 Mon Sep 17 00:00:00 2001 From: tTh Date: Sun, 1 Jan 2023 14:28:52 +0100 Subject: [PATCH] split julia --- Fraktalism/.gitignore | 2 +- Fraktalism/Makefile | 9 ++++--- Fraktalism/fraktals.f90 | 56 ---------------------------------------- Fraktalism/julias.f90 | 52 +++++++++++++++++++++++++++++++++++++ Fraktalism/mkjulia.f90 | 33 +++++++++++++++++++++++ Fraktalism/mkjuliagif.sh | 12 ++++----- 6 files changed, 98 insertions(+), 66 deletions(-) create mode 100644 Fraktalism/julias.f90 create mode 100644 Fraktalism/mkjulia.f90 diff --git a/Fraktalism/.gitignore b/Fraktalism/.gitignore index 7122cf5..b971dd2 100644 --- a/Fraktalism/.gitignore +++ b/Fraktalism/.gitignore @@ -1,5 +1,5 @@ -julia +mkjulia pickover lorentz mkmandel diff --git a/Fraktalism/Makefile b/Fraktalism/Makefile index c9f8177..76c0304 100644 --- a/Fraktalism/Makefile +++ b/Fraktalism/Makefile @@ -1,5 +1,5 @@ -all: voxelize evolvopick pickover julia lorentz essai \ +all: voxelize evolvopick pickover mkjulia lorentz essai \ mkmandel GFOPT = -Wall -Wextra -time -g -Imods/ -I../Modules @@ -20,8 +20,11 @@ fraktals.o: fraktals.f90 Makefile mandelbrots.o: mandelbrots.f90 Makefile gfortran $(GFOPT) -c $< +julias.o: julias.f90 Makefile + gfortran $(GFOPT) -c $< + OBJDEP = mods/points3d.o mods/xperiment.o mods/fractcolmap.o \ - fraktals.o mandelbrots.o + fraktals.o mandelbrots.o julias.o OBJS = $(OBJDEP) ../Modules/pixrgb.o ../Modules/spitpgm.o @@ -38,7 +41,7 @@ plotcolmap: plotcolmap.f90 Makefile $(OBJDEP) henon: henon.f90 Makefile $(OBJDEP) gfortran $(GFOPT) $< $(OBJS) -o $@ -julia: julia.f90 Makefile $(OBJDEP) +mkjulia: mkjulia.f90 Makefile $(OBJDEP) gfortran $(GFOPT) $< $(OBJS) -o $@ pickover: pickover.f90 Makefile $(OBJDEP) diff --git a/Fraktalism/fraktals.f90 b/Fraktalism/fraktals.f90 index a8d2909..b82ee52 100644 --- a/Fraktalism/fraktals.f90 +++ b/Fraktalism/fraktals.f90 @@ -1,15 +1,8 @@ module fraktals - use points3d - implicit none contains -!=============================================================== -!- -! Enfin un debut de Mandelbrot :) -!- - !=============================================================== ! nouveau 28 mai 2022 (again) ! source: @@ -44,55 +37,6 @@ subroutine parasites_0(pic, cx, cy, maxiter) end subroutine parasites_0 !=============================================================== !- -! some problems with color mapping, need more work -!- -subroutine simple_julia(pic, cx, cy, maxiter) - implicit none - integer, intent(inout), dimension (:,:) :: pic - real, intent(in) :: cx, cy - integer, intent(in) :: maxiter - - integer :: ix, iy, width, height - real :: fx, fy - complex :: Z, C - integer :: iter - logical :: over_iter - - width = ubound(pic, 1) - height = ubound(pic, 2) - - C = complex(cx, cy) - print *, "Const = ", C - - ! ready ? ok, clear the picture - pic = 0 - - do ix = 1, width - fx = (float(ix) / (float(width)/4.0) - 2.0) - do iy = 1, height - fy = (float(iy) / (float(height)/4.0) - 2.0) - ! ------ traitement du pixel - iter = 0 ; over_iter = .FALSE. - Z = complex(fx, fy) - do while (modulus2(Z) .LT. 4.0) - Z = (Z * Z) + C - iter = iter + 1 - if (iter .GE. maxiter) then - over_iter = .TRUE. - exit - endif - end do - if (over_iter) then - pic(ix, iy) = 0 - else - pic(ix, iy) = iter*12 - endif - enddo ! iy - enddo ! ix - -end subroutine simple_julia -!=============================================================== -!- ! d'après les pages 91/92 du livre de Roger T Stevens ! "Fractal programming in C" !- diff --git a/Fraktalism/julias.f90 b/Fraktalism/julias.f90 new file mode 100644 index 0000000..f764cea --- /dev/null +++ b/Fraktalism/julias.f90 @@ -0,0 +1,52 @@ +module julias + implicit none + contains + +!=============================================================== +!- +! some problems with color mapping, need more work +!- +subroutine simple_julia(pic, cx, cy, maxiter) + implicit none + integer, intent(inout), dimension (:,:) :: pic + real, intent(in) :: cx, cy + integer, intent(in) :: maxiter + + integer :: ix, iy, width, height + real :: fx, fy, fv + complex :: Z, C + integer :: iter + logical :: over_iter + + width = ubound(pic, 1) + height = ubound(pic, 2) + C = complex(cx, cy) + print *, "Const = ", C + ! ready ? ok, clear the picture + pic = 0 + do ix = 1, width + fx = (float(ix) / (float(width)/4.0) - 2.0) + do iy = 1, height + fy = (float(iy) / (float(height)/4.0) - 2.0) + ! ------ traitement du pixel + iter = 0 ; over_iter = .FALSE. + Z = complex(fx, fy) + do while (real(Z)*real(Z) + imag(Z)*imag(Z) .LT. 4.0) + Z = (Z * Z) + C + iter = iter + 1 + if (iter .GE. maxiter) then + over_iter = .TRUE. + exit + endif + end do + if (over_iter) then + pic(ix, iy) = 0 + else + pic(ix, iy) = iter*12 + endif + enddo ! iy + enddo ! ix + +end subroutine simple_julia +!=============================================================== +end module diff --git a/Fraktalism/mkjulia.f90 b/Fraktalism/mkjulia.f90 new file mode 100644 index 0000000..ddd9a83 --- /dev/null +++ b/Fraktalism/mkjulia.f90 @@ -0,0 +1,33 @@ +!----------------------------------------------------- +! JULIA +! ===== +! this is the main program +!----------------------------------------------------- + +program julia + + use spitpgm + use JULIAS + + implicit none + + integer, dimension(640, 480) :: picz + integer :: argc + character(200) :: filename, string + real :: cx, cy + + argc = IARGC() + if (3 .NE. argc) then + STOP ": MKJULIA PROGGY NEED 3 PARAMETERS !" + endif + + call getarg(1, filename) + call getarg(2, string) ; read (string, *) cx + call getarg(3, string) ; read (string, *) cy + + call simple_julia(picz, cx, cy, 3500) + call spit_as_pgm_8(picz, trim(filename)) + +end program + +!----------------------------------------------------- diff --git a/Fraktalism/mkjuliagif.sh b/Fraktalism/mkjuliagif.sh index d424685..defedf6 100755 --- a/Fraktalism/mkjuliagif.sh +++ b/Fraktalism/mkjuliagif.sh @@ -4,7 +4,7 @@ # build the prog # -make julia +make mkjulia if [ $? -ne 0 ] ; then echo echo "Make error " $? @@ -18,16 +18,16 @@ for foo in $(seq 0 99) do img=$(printf "frames/julia/%05d.pgm" $foo) - bar=$(echo "$foo / 247.0" | bc -l) - cx=$(echo "0.3 * c($foo/3)" | bc -l) - cy=$(echo "0.3 * s($foo/2)" | bc -l) + bar=$(echo "$foo / 247.0" | bc -l) + cx=$(echo "0.7 * (2.72*c($foo/3))" | bc -l) + cy=$(echo "0.5 * (1.45+s($foo/2))" | bc -l) - ./julia $img $cx $cy + ./mkjulia $img $cx $cy done echo ; echo "Encoding, please wait..." convert -delay 10 frames/julia/*.pgm foo.gif -animate foo.gif & +# animate foo.gif &