planeBoxOverlap Function

private function planeBoxOverlap(normal, origin, boxhalfwidth) result(overlaps)

This routine checks for plane box overlap this routine is conversion of c-code tribox3.c planeBoxOverlap function

Arguments

Type IntentOptional Attributes Name
real(kind=rk), intent(in) :: normal(3)

normal direction of the plane

real(kind=rk), intent(in) :: origin(3)

origin of the plane

real(kind=rk), intent(in) :: boxhalfwidth(3)

halfwidth of the box

Return Value logical


Called by

proc~~planeboxoverlap~~CalledByGraph proc~planeboxoverlap planeBoxOverlap proc~triboxoverlap_loc triBoxOverlap_loc proc~triboxoverlap_loc->proc~planeboxoverlap 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 planeBoxOverlap( normal, origin, boxhalfwidth ) result(overlaps)
    !--------------------------------------------------------------------------!
    !> normal direction of the plane
    real(kind=rk), intent(in) :: normal(3)
    !> origin of the plane
    real(kind=rk), intent(in) :: origin(3)
    !> halfwidth of the box
    real(kind=rk), intent(in) :: boxhalfwidth(3)
    logical :: overlaps
    !--------------------------------------------------------------------------!
    integer :: iDir
    real(kind=rk) :: vmin(3), vmax(3), tmp
    !--------------------------------------------------------------------------!
    overlaps = .false.
    ! find min and max of x,y,z of distance between boxhalfwidth and origin
    ! depends on the direction of the plane normal
    do iDir=1,3
      tmp = origin(iDir)
      if(normal(iDir) > 0.0_rk) then
        vmin(iDir) = - boxhalfwidth(iDir) - tmp
        vmax(iDir) =   boxhalfwidth(iDir) - tmp
      else
        vmin(iDir) =   boxhalfwidth(iDir) - tmp
        vmax(iDir) = - boxhalfwidth(iDir) - tmp
      endif
    end do

    if(dot_product(normal, vmin) > 0.0_rk) return

    if(dot_product(normal, vmax) >= 0.0_rk) overlaps = .true.

  end function planeBoxOverlap