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~~CallsGraph proc~axistest Axistest proc~cross_product3d cross_product3D proc~axistest->proc~cross_product3d

Called by

proc~~axistest~~CalledByGraph proc~axistest Axistest proc~triboxoverlap_loc triBoxOverlap_loc proc~triboxoverlap_loc->proc~axistest proc~tem_trianglecubeoverlap tem_triangleCubeOverlap proc~tem_trianglecubeoverlap->proc~triboxoverlap_loc proc~tem_planecubeoverlap tem_planeCubeOverlap proc~tem_planecubeoverlap->proc~tem_trianglecubeoverlap proc~tem_stlcubeoverlap tem_stlCubeOverlap proc~tem_stlcubeoverlap->proc~tem_trianglecubeoverlap proc~tem_planecubeoverlap~2 tem_planeCubeOverlap proc~tem_planecubeoverlap~2->proc~tem_trianglecubeoverlap proc~tem_shape_subtreefromgeominters tem_shape_subTreeFromGeomInters proc~tem_shape_subtreefromgeominters->proc~tem_trianglecubeoverlap proc~tem_shape_subtreefromgeominters->proc~tem_stlcubeoverlap proc~tem_boxcubeoverlap tem_boxCubeOverlap proc~tem_boxcubeoverlap->proc~tem_planecubeoverlap proc~tem_shape2subtree tem_shape2subTree proc~tem_shape2subtree->proc~tem_shape_subtreefromgeominters proc~tem_cano_initsubtree tem_cano_initSubTree proc~tem_cano_initsubtree->proc~tem_planecubeoverlap proc~tem_boxcubeoverlap~2 tem_boxCubeOverlap proc~tem_boxcubeoverlap~2->proc~tem_planecubeoverlap

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