on_line_2d Function

public function on_line_2d(P, A, B)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: P(2)
integer, intent(in) :: A(2)
integer, intent(in) :: B(2)

Return Value logical


Contents

Source Code


Source Code

    logical function on_line_2d(P, A, B)
        integer, intent(in) :: P(2), A(2), B(2)
        ! function to check if a point is on a line(for integers now only!)

        integer :: AB(2), AP(2)

        AB = B - A
        AP = P - A

        on_line_2d = .false.

        if (AB(1) * AP(2) - AB(2) * AP(1) == 0) on_line_2d = .true.

    end function on_line_2d