Axistest Function

private function Axistest(dirVec, edge, nodes, boxhalfwidth) result(success)

This function check whether there is separating axis between triangle and box. This function can be optimized by explicitly providing cross_product result see example: http://fileadmin.cs.lth.se/cs/Personal/Tomas_Akenine-Moller/code/tribox3.txt

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: dirVec(3)
real(kind=rk), intent(in) :: edge(3)
real(kind=rk), intent(in) :: nodes(3,3)
real(kind=rk), intent(in) :: boxhalfwidth(3)

Return Value logical


Calls

proc~~axistest~2~~CallsGraph proc~axistest~2 Axistest proc~cross_product3d cross_product3D proc~axistest~2->proc~cross_product3d

Called by

proc~~axistest~2~~CalledByGraph proc~axistest~2 Axistest proc~triboxoverlap_loc~2 triBoxOverlap_loc proc~triboxoverlap_loc~2->proc~axistest~2 proc~tem_trianglecubeoverlap~2 tem_triangleCubeOverlap proc~tem_trianglecubeoverlap~2->proc~triboxoverlap_loc~2

Contents

Source Code


Source Code

  function Axistest( dirVec, edge, nodes, boxhalfwidth ) result (success)
    !--------------------------------------------------------------------------!
    real(kind=rk), intent(in) :: dirVec(3)
    real(kind=rk), intent(in) :: edge(3)
    real(kind=rk), intent(in) :: nodes(3,3)
    real(kind=rk), intent(in) :: boxhalfwidth(3)
    logical :: success
    !--------------------------------------------------------------------------!
    real(kind=rk) :: vecA(3), p1, p2, p3, pmin, pmax, rad
    !--------------------------------------------------------------------------!

    success = .true.

    ! a_(i,j) = e_i x f_j
    vecA = cross_product3D( dirVec, edge )

    p1 = dot_product( vecA, nodes(:,1) )
    p2 = dot_product( vecA, nodes(:,2) )
    p3 = dot_product( vecA, nodes(:,3) )

    pmin = min(p1, p2, p3)
    pmax = max(p1, p2, p3)

    rad = abs(vecA(1)) * boxhalfwidth(1) &
      & + abs(vecA(2)) * boxhalfwidth(2) &
      & + abs(vecA(3)) * boxhalfwidth(3)

    if (pmin > rad .or. pmax < -rad) return

    success = .false.

  end function Axistest