+ pickover

This commit is contained in:
tth 2022-02-14 14:15:10 +01:00
parent 123c87b126
commit 0b94fae700
5 changed files with 60 additions and 16 deletions

View File

@ -1,5 +1,6 @@
julia julia
pickover
*.pgm *.pgm
*.gif *.gif

View File

@ -16,4 +16,7 @@ OBJS = spitpgm.o fraktals.o
julia: julia.f90 Makefile $(OBJS) julia: julia.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@ gfortran $(GFOPT) $< $(OBJS) -o $@
pickover: pickover.f90 Makefile $(OBJS)
gfortran $(GFOPT) $< $(OBJS) -o $@
# --------------------------------------------- # ---------------------------------------------

View File

@ -13,14 +13,13 @@ subroutine simple_julia(pic, cx, cy, maxiter)
real :: fx, fy real :: fx, fy
complex :: Z, C complex :: Z, C
integer :: iter integer :: iter
logical :: over_iter
width = ubound(pic, 1) width = ubound(pic, 1)
height = ubound(pic, 2) height = ubound(pic, 2)
! print *, "image size : ", width, height
! print *, "constante : ", cx, cy
C = complex(cx, cy) C = complex(cx, cy)
! print *, "C = ", C print *, "Const = ", C
do ix = 1, width do ix = 1, width
fx = (float(ix) / (float(width)/4.0) - 2.0) fx = (float(ix) / (float(width)/4.0) - 2.0)
@ -28,24 +27,65 @@ subroutine simple_julia(pic, cx, cy, maxiter)
fy = (float(iy) / (float(height)/4.0) - 2.0) fy = (float(iy) / (float(height)/4.0) - 2.0)
! ------ traitement du pixel ! ------ traitement du pixel
iter = 0 iter = 0 ; over_iter = .FALSE.
Z = complex(fx, fy) Z = complex(fx, fy)
do while ( (modulus2(Z) .LT. 4.0) .AND. & do while (modulus2(Z) .LT. 4.0)
(iter < maxiter) )
Z = (Z * Z) + C Z = (Z * Z) + C
iter = iter + 1 iter = iter + 1
if (iter .GE. maxiter) then
over_iter = .TRUE.
exit
endif
end do end do
pic(ix, iy) = iter if (over_iter) then
pic(ix, iy) = 0
! print *, ix, iy, " ", fx, fy, " ", iter else
pic(ix, iy) = iter
endif
enddo enddo
enddo enddo
end subroutine end subroutine simple_julia
!----------------------------------------------------- !-----------------------------------------------------
!
!
!
subroutine pickover_0(pic, count)
implicit none
integer, intent(inout), dimension (:,:) :: pic
integer, intent(in) :: count
double precision :: xa, ya, za, xb, yb, zb
double precision :: ka, kb, kc, kd
integer :: i, px, py
ka = 2.24 ; kb = 0.43 ; kc = -0.65 ; kd = -2.43
xa = 0.00 ; ya = 0.00 ; za = 0.0
do i=1, count
xb = sin(ka*ya) - za*cos(kb*xa)
yb = za*sin(kc*xa) - cos(kd*ya)
zb = sin(xa)
print *, i, xb, yb, zb
xa = xb ; ya = yb ; za = zb
enddo
end subroutine pickover_0
!-----------------------------------------------------
! -- some support functions --
!-----------------------------------------------------
function dist0 (x, y) function dist0 (x, y)
implicit none implicit none
real, intent(in) :: x, y real, intent(in) :: x, y

View File

@ -10,21 +10,21 @@ program julia
implicit none implicit none
integer, dimension(640, 480) :: picz integer, dimension(512, 342) :: picz
integer :: argc integer :: argc
character(200) :: filename, string character(200) :: filename, string
real :: cx, cy real :: cx, cy
argc = IARGC() argc = IARGC()
if (3 .NE. argc) then if (3 .NE. argc) then
STOP ": JULIA PROGGY NEED PARAMETERS" STOP ": JULIA PROGGY NEED PARAMETERS !"
endif endif
call getarg(1, filename) call getarg(1, filename)
call getarg(2, string) ; read (string, *) cx call getarg(2, string) ; read (string, *) cx
call getarg(3, string) ; read (string, *) cy call getarg(3, string) ; read (string, *) cy
call simple_julia(picz, cx, cy, 120) call simple_julia(picz, cx, cy, 250)
call spit_as_pgm_8(picz, trim(filename)) call spit_as_pgm_8(picz, trim(filename))
end program end program

View File

@ -15,7 +15,7 @@ subroutine spit_as_pgm(pic, fname)
integer :: ix, iy integer :: ix, iy
real :: fk, fpix real :: fk, fpix
print *, "> spit_as_pgm to ", fname ! XXX print *, "> spit_as_pgm to ", fname
open(newunit=io, file=fname) open(newunit=io, file=fname)
write (io, '(a2)') "P2" write (io, '(a2)') "P2"
@ -50,9 +50,9 @@ subroutine spit_as_pgm_8(pic, fname)
integer :: io, foo integer :: io, foo
integer :: ix, iy integer :: ix, iy
print *, "> spit_as_pgm_8 to ", fname ! XXX print *, "> spit_as_pgm_8 to ", fname
foo = MAXVAL(pic) foo = MAXVAL(pic)
print *, " max = ", foo ! XXX print *, " max = ", foo
open(newunit=io, file=fname) open(newunit=io, file=fname)
write (io, '(a2)') "P2" write (io, '(a2)') "P2"
write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2) write (io, '(i0," ",i0)') size(pic, 1), size(pic, 2)