split julia

This commit is contained in:
tTh 2023-01-01 14:28:52 +01:00
parent 1b3f93ecfe
commit da56a6d0c0
6 changed files with 98 additions and 66 deletions

View File

@ -1,5 +1,5 @@
julia mkjulia
pickover pickover
lorentz lorentz
mkmandel mkmandel

View File

@ -1,5 +1,5 @@
all: voxelize evolvopick pickover julia lorentz essai \ all: voxelize evolvopick pickover mkjulia lorentz essai \
mkmandel mkmandel
GFOPT = -Wall -Wextra -time -g -Imods/ -I../Modules GFOPT = -Wall -Wextra -time -g -Imods/ -I../Modules
@ -20,8 +20,11 @@ fraktals.o: fraktals.f90 Makefile
mandelbrots.o: mandelbrots.f90 Makefile mandelbrots.o: mandelbrots.f90 Makefile
gfortran $(GFOPT) -c $< gfortran $(GFOPT) -c $<
julias.o: julias.f90 Makefile
gfortran $(GFOPT) -c $<
OBJDEP = mods/points3d.o mods/xperiment.o mods/fractcolmap.o \ 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 OBJS = $(OBJDEP) ../Modules/pixrgb.o ../Modules/spitpgm.o
@ -38,7 +41,7 @@ plotcolmap: plotcolmap.f90 Makefile $(OBJDEP)
henon: henon.f90 Makefile $(OBJDEP) henon: henon.f90 Makefile $(OBJDEP)
gfortran $(GFOPT) $< $(OBJS) -o $@ gfortran $(GFOPT) $< $(OBJS) -o $@
julia: julia.f90 Makefile $(OBJDEP) mkjulia: mkjulia.f90 Makefile $(OBJDEP)
gfortran $(GFOPT) $< $(OBJS) -o $@ gfortran $(GFOPT) $< $(OBJS) -o $@
pickover: pickover.f90 Makefile $(OBJDEP) pickover: pickover.f90 Makefile $(OBJDEP)

View File

@ -1,15 +1,8 @@
module fraktals module fraktals
use points3d use points3d
implicit none implicit none
contains contains
!===============================================================
!-
! Enfin un debut de Mandelbrot :)
!-
!=============================================================== !===============================================================
! nouveau 28 mai 2022 (again) ! nouveau 28 mai 2022 (again)
! source: ! source:
@ -44,55 +37,6 @@ subroutine parasites_0(pic, cx, cy, maxiter)
end subroutine parasites_0 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 ! d'après les pages 91/92 du livre de Roger T Stevens
! "Fractal programming in C" ! "Fractal programming in C"
!- !-

52
Fraktalism/julias.f90 Normal file
View File

@ -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

33
Fraktalism/mkjulia.f90 Normal file
View File

@ -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
!-----------------------------------------------------

View File

@ -4,7 +4,7 @@
# build the prog # build the prog
# #
make julia make mkjulia
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo echo
echo "Make error " $? echo "Make error " $?
@ -19,15 +19,15 @@ do
img=$(printf "frames/julia/%05d.pgm" $foo) img=$(printf "frames/julia/%05d.pgm" $foo)
bar=$(echo "$foo / 247.0" | bc -l) bar=$(echo "$foo / 247.0" | bc -l)
cx=$(echo "0.3 * c($foo/3)" | bc -l) cx=$(echo "0.7 * (2.72*c($foo/3))" | bc -l)
cy=$(echo "0.3 * s($foo/2)" | bc -l) cy=$(echo "0.5 * (1.45+s($foo/2))" | bc -l)
./julia $img $cx $cy ./mkjulia $img $cx $cy
done done
echo ; echo "Encoding, please wait..." echo ; echo "Encoding, please wait..."
convert -delay 10 frames/julia/*.pgm foo.gif convert -delay 10 frames/julia/*.pgm foo.gif
animate foo.gif & # animate foo.gif &