diff --git a/GravityField/.gitignore b/GravityField/.gitignore index 1981612..e84bca6 100644 --- a/GravityField/.gitignore +++ b/GravityField/.gitignore @@ -1,6 +1,7 @@ essai animation +realdump2png WS/*.pgm WS/*.png diff --git a/GravityField/Makefile b/GravityField/Makefile index f971c1a..158dd37 100644 --- a/GravityField/Makefile +++ b/GravityField/Makefile @@ -5,7 +5,7 @@ GFOPT = -Wall -Wextra -g -time -I../Modules MODOBJ = ../Modules/spitpgm.o ../Modules/pixrgb.o -all: essai animation +all: essai animation realdump2png # ----------- modules @@ -20,4 +20,7 @@ essai: essai.f90 Makefile realfield.o animation: animation.f90 Makefile realfield.o gfortran $(GFOPT) $< realfield.o $(MODOBJ) -o $@ -#- +realdump2png: realdump2png.f90 Makefile realfield.o + gfortran $(GFOPT) $< realfield.o $(MODOBJ) -o $@ + +#- remember bro: yolo forever :) diff --git a/GravityField/WS/field/README.md b/GravityField/WS/field/README.md deleted file mode 100644 index 1dac8fa..0000000 --- a/GravityField/WS/field/README.md +++ /dev/null @@ -1,2 +0,0 @@ - -# placeholder diff --git a/GravityField/WS/nanim/README.md b/GravityField/WS/nanim/README.md deleted file mode 100644 index 1dac8fa..0000000 --- a/GravityField/WS/nanim/README.md +++ /dev/null @@ -1,2 +0,0 @@ - -# placeholder diff --git a/GravityField/WS/troid/README.md b/GravityField/WS/troid/README.md deleted file mode 100644 index 1dac8fa..0000000 --- a/GravityField/WS/troid/README.md +++ /dev/null @@ -1,2 +0,0 @@ - -# placeholder diff --git a/GravityField/animation.f90 b/GravityField/animation.f90 index 5ff50e6..0df5e70 100644 --- a/GravityField/animation.f90 +++ b/GravityField/animation.f90 @@ -13,18 +13,16 @@ program animation implicit none ! some configuration constants - integer, parameter :: S_WIDTH = 1024 - integer, parameter :: S_HEIGHT = 1024 - integer, parameter :: NB_BODY = 51 + integer, parameter :: S_WIDTH = 2048 + integer, parameter :: S_HEIGHT = 2048 + integer, parameter :: NB_BODY = 250 !!! WARNING : global variable !!! type(massbody) :: planets(NB_BODY) call init_random() call create_some_planets(planets, 1664e3, S_WIDTH , S_HEIGHT) - call print_barycentre_bodies(planets) - - ! STOP 'BEFORE CRASH' + call print_barycentre_bodies(planets, 'begin') call la_grande_boucle(0, 2000, planets) @@ -33,7 +31,7 @@ program animation !----------------------------------------------------------------------- contains !- -! fabrication d'une de la sequence complete +! fabrication de la sequence complete !- subroutine la_grande_boucle(start, nbre, moons) integer, intent(in) :: start, nbre @@ -47,19 +45,21 @@ subroutine la_grande_boucle(start, nbre, moons) ! else use ?????ing call deplace_les_planetes(moons, .TRUE.) + ! computing the field (used as a HF in Povray write (filename, "(a, i5.5, a)") 'WS/nanim/', pass, '.pgm' write(0, '(3I5, " * ", a20)') start, nbre, pass, filename call build_and_write_a_field(S_WIDTH, S_HEIGHT, moons, filename) - write (filename, "(a, i5.5, a)") 'WS/data/', pass, '.txt' - call save_bodies_to_txt_file (planets, filename) + ! save the current bodies positions (can be used in gnuplot) + ! write (filename, "(a, i5.5, a)") 'WS/data/', pass, '.txt' + ! call save_bodies_to_txt_file (planets, filename) write (filename, "(a, i5.5, a)") 'WS/colmap/', pass, '.pnm' call make_color_map(planets, filename, S_WIDTH, S_HEIGHT) enddo -call print_barycentre_bodies(moons) +call print_barycentre_bodies(moons, 'end') end subroutine @@ -72,11 +72,11 @@ subroutine make_color_map(moons, fname, width, height) character(len=*), intent(in) :: fname integer, intent(in) :: width, height - type(t_pixrgb), dimension(:,:), allocatable :: cmap - integer :: ix, iy, near, ipl - integer :: errcode - real :: curdist, smalldist - real :: fx, fy, dx, dy + type(t_pixrgb), dimension(:,:), allocatable :: cmap + integer :: ix, iy, near, ipl + integer :: errcode + real :: curdist, smalldist + real :: fx, fy, dx, dy write(0, *) "colmap ", ubound(moons, 1), "moons to ", trim(fname) ! write(0, *) "mapsize ", width, height @@ -107,14 +107,14 @@ subroutine make_color_map(moons, fname, width, height) endif end do ! loop on all the moons, ipl index - cmap(ix, iy)%r = mod(near*13, 255) - cmap(ix, iy)%g = mod(near*14, 255) - cmap(ix, iy)%b = mod(near*15, 255) + cmap(ix, iy)%r = mod(near*3, 255) + cmap(ix, iy)%g = mod(near*4, 255) + cmap(ix, iy)%b = mod(near*5, 255) enddo enddo - call rgbpix_spit_as_pnm(cmap, fname) + call rgbpix_spit_as_pnm_8(cmap, fname) deallocate(cmap) @@ -131,9 +131,9 @@ subroutine deplace_les_planetes(moons, clipit) logical, intent(in) :: clipit integer :: foo - real :: depx, depy + real :: depx, depy, coef - integer, parameter :: EE = 51 + integer, parameter :: EE = 100 integer :: SW = S_WIDTH - EE integer :: SH = S_HEIGHT - EE @@ -162,7 +162,12 @@ subroutine deplace_les_planetes(moons, clipit) if (moons(foo)%posy .LT. EE) moons(foo)%posy = SH endif - moons(foo)%heading = moons(foo)%heading + (0.78*(rand()-0.50)) + if (rand() .LT. 0.15) then + coef = 1.63 + else + coef = 0.78 + endif + moons(foo)%heading = moons(foo)%heading + (coef*(rand()-0.42)) if (moons(foo)%heading .GT. 6.283185307) moons(foo)%heading = 0.0 if (moons(foo)%heading .LT. 0.000000001) moons(foo)%heading = 0.0 diff --git a/GravityField/encode.sh b/GravityField/encode.sh index c005450..478f6c5 100755 --- a/GravityField/encode.sh +++ b/GravityField/encode.sh @@ -23,7 +23,7 @@ echo "file type :" $filetype case $filetype in PNG) extension=".png" ;; Netpbm) extension=".pgm" ;; - *) extension=".binary" ;; + *) extension=".pnm" ;; esac echo "extension :" $extension diff --git a/GravityField/essai.f90 b/GravityField/essai.f90 index 64b6b3f..8231e96 100644 --- a/GravityField/essai.f90 +++ b/GravityField/essai.f90 @@ -12,7 +12,7 @@ program essai call init_random() - call essai_near_planet(1024, 1024) + call essai_near_planet(2048, 2048) STOP 'BECAUSE YOLO' @@ -74,7 +74,7 @@ subroutine essai_near_planet(nbplanets, szfield) enddo - call rgbpix_spit_as_pnm(cmap, "rgb.pnm") + call rgbpix_spit_as_pnm_8(cmap, "rgb.pnm") end subroutine !----------------------------------------------------------------------- diff --git a/GravityField/raytrace.sh b/GravityField/raytrace.sh index 59a2945..043833e 100755 --- a/GravityField/raytrace.sh +++ b/GravityField/raytrace.sh @@ -2,7 +2,7 @@ set -e -POVOPT=" -q9 +a -W1024 -H768 +WT2 -d -v " +POVOPT=" -q9 +a -W1280 -H1024 +WT2 -d -v " SOURCE="vision.pov" TMPF="/dev/shm/gravfield.png" @@ -29,10 +29,12 @@ convert ${TMPF} \ -fill Orange \ -annotate +15+22 "$timestamp" \ -annotate +15+48 "$texte" \ - -pointsize 16 \ + -pointsize 14 \ -gravity south-west \ -annotate +15+9 "tTh & Konrad" \ ${outfile} + +sleep 3 } # --------------------------------------- @@ -51,5 +53,6 @@ ffmpeg -nostdin \ -metadata artist='---{ tTh and Konrad }---' \ -metadata title="Experiment on Gravity Field" \ -c:v libx264 -pix_fmt yuv420p \ - bar.mp4 + -preset veryslow \ + gravity-field.mp4 diff --git a/GravityField/realdump2png.f90 b/GravityField/realdump2png.f90 new file mode 100644 index 0000000..47c2520 --- /dev/null +++ b/GravityField/realdump2png.f90 @@ -0,0 +1,23 @@ +!----------------------------------------------------------------------- +!- +! convertir un dum de champ de reel en .PNG +! nouveau 17 decembre 2022 +!- +!----------------------------------------------------------------------- +program realdump2png + use realfield + implicit none + + stop "BECAUSE I'M TIRED *NOW*" + +contains +!----------------------------------------------------------------------- + +subroutine load_a_dump_file(fname, location) + character(len=*), intent(in) :: fname + real, dimension(:,:), intent(inout) :: location + +end subroutine +!----------------------------------------------------------------------- +end program +!----------------------------------------------------------------------- diff --git a/GravityField/realfield.f90 b/GravityField/realfield.f90 index 66c99c8..0581e0a 100644 --- a/GravityField/realfield.f90 +++ b/GravityField/realfield.f90 @@ -29,7 +29,7 @@ subroutine compute_barycentre_bodies(astres, bcx, bcy) integer :: foo real :: cx, cy - ! May be we have to use DOUBLE RPECSION here ? + ! May be we have to use DOUBLE PRECSION here ? cx = 0.0 cy = 0.0 do foo=1, ubound(astres, 1) @@ -40,12 +40,13 @@ subroutine compute_barycentre_bodies(astres, bcx, bcy) bcy = cy / real(ubound(astres, 1)) end subroutine !----------------------------------------------------------------------- -subroutine print_barycentre_bodies(astres) +subroutine print_barycentre_bodies(astres, title) type(massbody), intent(in) :: astres(:) - real :: cx, cy + character(len=*), intent(in) :: title + real :: cx, cy call compute_barycentre_bodies(astres, cx, cy) - print *, "barycentre : ", cx, cy + print *, "barycentre {", title, "} ", cx, cy end subroutine !----------------------------------------------------------------------- @@ -81,8 +82,8 @@ subroutine create_some_planets(planets, coef, sx, sy) !- planets(foo)%posx = rand() * real(sx-1) planets(foo)%posy = rand() * real(sy-1) - planets(foo)%mass = 7e6 + coef*foo - planets(foo)%heading = 2 * 3.14159 * rand() + planets(foo)%mass = 7.12e6 + coef*foo + planets(foo)%heading = 2 * 3.141592654 * rand() if (rand() .LT. 0.15) planets(foo)%speed = 3.14159 planets(foo)%serial = foo*2 + 120 endif diff --git a/GravityField/runme.sh b/GravityField/runme.sh index 722bc77..c898c66 100755 --- a/GravityField/runme.sh +++ b/GravityField/runme.sh @@ -4,9 +4,13 @@ set -e # stop on error make animation -date > animation.log +LOG="log.animation" -time ./animation | tee animation.log +date >> $LOG -./encode.sh WS/nanim/ quux.mp4 -./encode.sh WS/colmap/ zzz.mp4 +time ./animation | tee -a $LOG + +./encode.sh WS/nanim/ gravity-field.mp4 +./encode.sh WS/colmap/ gravity-colmap.mp4 + +ls -rtl *.mp4 >> $LOG diff --git a/GravityField/vision.pov b/GravityField/vision.pov index bf3d4f4..002c7ce 100644 --- a/GravityField/vision.pov +++ b/GravityField/vision.pov @@ -45,7 +45,7 @@ texture { } } -object { GravityField scale <4, 0.60, 4> } +object { GravityField scale <4.10, 0.60, 4.10> } // ---------------------------------------------------------------------- @@ -58,13 +58,13 @@ merge { XXX */ light_source { < -2, 9.3, -7> color Gray90 } -light_source { < -6, 9.3, -8> color Orange*0.75 } -light_source { < -15, 2.3, 17> color Green*0.25 } +light_source { < -6, 9.3, -8> color Orange*0.65 } +light_source { < -15, 2.3, 17> color Gray70 } // ---------------------------------------------------------------------- camera { - location <-8, 4-(1.5*NormClock), 1 + (5*NormClock)> + location <-8, 4-(1.7*NormClock), -4 + (11.66*NormClock)> look_at <0, 0, 0> right x*image_width/image_height angle 33