geometry_unit_test Subroutine

public subroutine geometry_unit_test()

Unit test routine

Output

x0,y0=  0.59999999999999998       0.59999999999999998
l=           1
m=          -1
dist to path=  0.40000000000000002

x0,y0=   1.5000000000000000       0.50000000000000000
l=          -1
m=           0
dist to path= -0.50000000000000000

x0,y0=   1.0000000000000000        0.0000000000000000
l=           0
m=           0
dist to path=   0.0000000000000000

Arguments

None

Calls

proc~~geometry_unit_test~~CallsGraph proc~geometry_unit_test geometry_module::geometry_unit_test proc~distance_from_point_to_path geometry_module::distance_from_point_to_path proc~geometry_unit_test->proc~distance_from_point_to_path proc~locpt geometry_module::locpt proc~geometry_unit_test->proc~locpt proc~distance_from_point_to_path->proc~locpt proc~distance_from_point_to_line_segment geometry_module::distance_from_point_to_line_segment proc~distance_from_point_to_path->proc~distance_from_point_to_line_segment

Source Code

    subroutine geometry_unit_test()

    implicit none

    integer   :: l,m
    real(wp)  :: x0,y0

    !a 1x1 square:
    integer,parameter :: n = 4
    real(wp),dimension(n),parameter :: x = [0.0_wp, 0.0_wp, 1.0_wp, 1.0_wp]
    real(wp),dimension(n),parameter :: y = [0.0_wp, 1.0_wp, 1.0_wp, 0.0_wp]

    x0 = 0.6_wp    !inside the path
    y0 = 0.6_wp
    call go()

    x0 = 1.5_wp    !outside the path
    y0 = 0.5_wp
    call go()

    x0 = 10.0_wp   !outside the path
    y0 = 0.0_wp
    call go()

    x0 = 1.0_wp    !on the path
    y0 = 0.0_wp
    call go()

    contains

        subroutine go()    !call locpt for the x0,y0 point, and print results
          implicit none

          real(wp) :: d

          call locpt (x0, y0, x, y, n, l, m)

          write(*,*) ''
          write(*,*) 'x0,y0=',x0,y0
          write(*,*) 'l=',l
          write(*,*) 'm=',m

          d = distance_from_point_to_path(x0, y0, x, y, n)
          write(*,*) 'dist to path=',d


        end subroutine go

    end subroutine geometry_unit_test