add rotation, need more tests
This commit is contained in:
7
Makefile
7
Makefile
@@ -7,8 +7,11 @@ all: testbed
|
|||||||
genplotting.o: genplotting.f90 Makefile
|
genplotting.o: genplotting.f90 Makefile
|
||||||
gfortran -Wall -c $<
|
gfortran -Wall -c $<
|
||||||
|
|
||||||
testbed: testbed.f90 Makefile genplotting.o
|
genp_tests.o: genp_tests.f90 genplotting.o Makefile
|
||||||
gfortran -Wall $< genplotting.o -o $@
|
gfortran -Wall -c $<
|
||||||
|
|
||||||
|
testbed: testbed.f90 Makefile genp_tests.o genplotting.o
|
||||||
|
gfortran -Wall $< genplotting.o genp_tests.o -o $@
|
||||||
|
|
||||||
# -----------------------------------------------
|
# -----------------------------------------------
|
||||||
|
|
||||||
|
|||||||
41
genp_tests.f90
Normal file
41
genp_tests.f90
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
!
|
||||||
|
! MODULE FOR TESTING THE GENPLOTTING MODULE
|
||||||
|
!
|
||||||
|
! this crapware is released by tTh under the
|
||||||
|
! DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
|
!
|
||||||
|
! new Sun May 17 11:21:39 AM UTC 2026
|
||||||
|
|
||||||
|
module genp_tests
|
||||||
|
use genplotting
|
||||||
|
implicit none
|
||||||
|
contains
|
||||||
|
! ---------------------------------------------------------
|
||||||
|
subroutine genp_test_rotation()
|
||||||
|
|
||||||
|
real :: mat(3, 3)
|
||||||
|
real :: pta(3), ptb(3)
|
||||||
|
integer :: pass, i, j
|
||||||
|
|
||||||
|
write(0, '("*** TEST ROTATION ***")' )
|
||||||
|
do pass=1, 90
|
||||||
|
call genp_set_rotation (real(pass)*0.10)
|
||||||
|
write(0, *) " * the matrix was : "
|
||||||
|
call genp_get_rot_matrix(mat)
|
||||||
|
do i=1, 3
|
||||||
|
do j=1, 3
|
||||||
|
write (0, '(" ", F8.5)', advance='no') mat(i,j)
|
||||||
|
end do
|
||||||
|
write(0, *)
|
||||||
|
end do
|
||||||
|
|
||||||
|
call genp_move(0.0, 0.0)
|
||||||
|
pta(1) = 11.0 ; pta(2) = 0.0 ; pta(3) = 0.0
|
||||||
|
ptb = matmul(mat, pta)
|
||||||
|
write(0, '(" got XY: ", F8.5, " ", F8.5)') ptb(1), ptb(2)
|
||||||
|
call genp_draw(ptb(1), ptb(2), 1+mod(pass, 7))
|
||||||
|
end do ! pass
|
||||||
|
|
||||||
|
end subroutine
|
||||||
|
! ---------------------------------------------------------
|
||||||
|
end module
|
||||||
@@ -11,8 +11,9 @@ module genplotting
|
|||||||
real :: xoffset, yoffset, xscale, yscale
|
real :: xoffset, yoffset, xscale, yscale
|
||||||
private :: xoffset, yoffset, xscale, yscale
|
private :: xoffset, yoffset, xscale, yscale
|
||||||
|
|
||||||
real :: rotation
|
real :: rotation, rotmatrix(3,3)
|
||||||
private :: rotation
|
private :: rotation, rotmatrix, compute_rot_matrix
|
||||||
|
private :: print_rot_matrix
|
||||||
|
|
||||||
integer :: outunit = 6
|
integer :: outunit = 6
|
||||||
private :: outunit
|
private :: outunit
|
||||||
@@ -21,7 +22,7 @@ contains
|
|||||||
! ---------------------------------------------------------
|
! ---------------------------------------------------------
|
||||||
! the first parameter _must_ be 0.
|
! the first parameter _must_ be 0.
|
||||||
! the second can be
|
! the second can be
|
||||||
! - the name of a file for recoding plot instructions
|
! - the name of a file for recording plot instructions
|
||||||
! or
|
! or
|
||||||
! - an empty string for send plot command to stdout
|
! - an empty string for send plot command to stdout
|
||||||
!
|
!
|
||||||
@@ -44,6 +45,7 @@ subroutine genp_init (foo, fname)
|
|||||||
ymin = 9e9 ; ymax = -9e9
|
ymin = 9e9 ; ymax = -9e9
|
||||||
xoffset = 0.0 ; yoffset = 0.0
|
xoffset = 0.0 ; yoffset = 0.0
|
||||||
xscale = 1.0 ; yscale = 1.0
|
xscale = 1.0 ; yscale = 1.0
|
||||||
|
|
||||||
rotation = 0.0
|
rotation = 0.0
|
||||||
|
|
||||||
end subroutine
|
end subroutine
|
||||||
@@ -67,6 +69,56 @@ subroutine genp_get_scale(sx, sy)
|
|||||||
sx = xscale ; sy = yscale
|
sx = xscale ; sy = yscale
|
||||||
end subroutine
|
end subroutine
|
||||||
! ---------------------------------------------------------
|
! ---------------------------------------------------------
|
||||||
|
! this is a private procedure, don't call it from your prog
|
||||||
|
subroutine compute_rot_matrix(angle)
|
||||||
|
real, intent(in) :: angle
|
||||||
|
write (0, '("compute rot matrix for", F8.5, " radians")') &
|
||||||
|
angle
|
||||||
|
rotmatrix (1, 1) = cos(angle)
|
||||||
|
rotmatrix (1, 2) = sin(angle)
|
||||||
|
rotmatrix (1, 3) = 0.0
|
||||||
|
|
||||||
|
rotmatrix (2, 1) = -sin(angle)
|
||||||
|
rotmatrix (2, 2) = cos(angle)
|
||||||
|
rotmatrix (2, 3) = 0.0
|
||||||
|
|
||||||
|
rotmatrix (3, 1) = 0.0
|
||||||
|
rotmatrix (3, 2) = 0.0
|
||||||
|
rotmatrix (3, 3) = 1.0
|
||||||
|
|
||||||
|
end subroutine
|
||||||
|
! -----------------
|
||||||
|
! we have computed some fancy numbers
|
||||||
|
! and we want to see them !
|
||||||
|
subroutine print_rot_matrix(fd)
|
||||||
|
integer, intent(in) :: fd
|
||||||
|
|
||||||
|
integer :: i, j
|
||||||
|
do i=1, 3
|
||||||
|
do j=1, 3
|
||||||
|
write (fd, '(" ", F8.5)', advance='no') rotmatrix(i,j)
|
||||||
|
end do
|
||||||
|
write(fd, *)
|
||||||
|
end do
|
||||||
|
end subroutine
|
||||||
|
! ---------------------------------------------------------
|
||||||
|
subroutine genp_set_rotation(angle)
|
||||||
|
real, intent(in) :: angle
|
||||||
|
rotation = angle
|
||||||
|
! compute the matrix here !
|
||||||
|
call compute_rot_matrix(angle)
|
||||||
|
! call print_rot_matrix(0)
|
||||||
|
end subroutine
|
||||||
|
|
||||||
|
real function genp_get_rotation()
|
||||||
|
genp_get_rotation = rotation
|
||||||
|
end function
|
||||||
|
|
||||||
|
subroutine genp_get_rot_matrix (dst)
|
||||||
|
real, intent(out) :: dst(3, 3)
|
||||||
|
dst = rotmatrix
|
||||||
|
end subroutine
|
||||||
|
! ---------------------------------------------------------
|
||||||
subroutine genp_move (px, py)
|
subroutine genp_move (px, py)
|
||||||
real, intent(in) :: px, py
|
real, intent(in) :: px, py
|
||||||
real :: lx, ly
|
real :: lx, ly
|
||||||
@@ -138,7 +190,7 @@ end subroutine
|
|||||||
subroutine genp_end (foo)
|
subroutine genp_end (foo)
|
||||||
integer, intent(in) :: foo
|
integer, intent(in) :: foo
|
||||||
|
|
||||||
write (0, '("--- genp_end ---")')
|
write (0, '("------------- genp_end -------------")')
|
||||||
write (0, '("minmax X ", 2F18.5)') xmin, xmax
|
write (0, '("minmax X ", 2F18.5)') xmin, xmax
|
||||||
write (0, '("minmax Y ", 2F18.5)') ymin, ymax
|
write (0, '("minmax Y ", 2F18.5)') ymin, ymax
|
||||||
|
|
||||||
|
|||||||
25
testbed.f90
25
testbed.f90
@@ -1,23 +1,18 @@
|
|||||||
|
!
|
||||||
|
! TESTBED FOR GENPLOTTING90
|
||||||
|
!
|
||||||
|
! this crapware is released by tTh under the
|
||||||
|
! DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
|
||||||
|
!
|
||||||
|
|
||||||
program testbed
|
program testbed
|
||||||
use genplotting
|
use genplotting
|
||||||
|
use genp_tests
|
||||||
implicit none
|
implicit none
|
||||||
|
|
||||||
integer idx
|
|
||||||
real fdx, xp, yp, scx, scy
|
|
||||||
|
|
||||||
call genp_init(0, "foo.scratch")
|
call genp_init(0, "foo.scratch")
|
||||||
scx = 0.8 ; scy = 1.5
|
call genp_test_rotation()
|
||||||
do idx=5, 60
|
! call genp_plot_axes(5.1)
|
||||||
fdx = real(idx)
|
|
||||||
xp = 3.5 * cos((fdx/14.0)-0.7)
|
|
||||||
yp = 3.5 * sin((fdx/10.0)+0.3)
|
|
||||||
call genp_set_offset(xp, yp)
|
|
||||||
call genp_set_scale(scx, scy)
|
|
||||||
call genp_circle(fdx, 60, 1+mod(idx, 3))
|
|
||||||
scx = scx + 0.0075
|
|
||||||
scy = scy - 0.0075
|
|
||||||
enddo
|
|
||||||
call genp_end(0)
|
call genp_end(0)
|
||||||
call genp_do_render("foo.scratch", "foo.tga", 512, 512)
|
|
||||||
|
|
||||||
end program
|
end program
|
||||||
|
|||||||
Reference in New Issue
Block a user