tem_lineCubeOverlap Function

public function tem_lineCubeOverlap(line, cube, pntIntersect) result(overlap)

Function computes intersection of line with cube

If optional argument pntIntersect contains the intersection point of the line with cube

Arguments

Type IntentOptional Attributes Name
type(tem_line_type), intent(in) :: line

line segment to check for intersection

type(tem_cube_type), intent(in) :: cube

cube to intersect with

real(kind=rk), intent(out), optional :: pntIntersect(3)

intersection point if there is intersection

Return Value logical


Calls

proc~~tem_linecubeoverlap~~CallsGraph proc~tem_linecubeoverlap tem_lineCubeOverlap proc~raycubeoverlap rayCubeOverlap proc~tem_linecubeoverlap->proc~raycubeoverlap

Called by

proc~~tem_linecubeoverlap~~CalledByGraph proc~tem_linecubeoverlap tem_lineCubeOverlap proc~tem_cano_initsubtree tem_cano_initSubTree proc~tem_cano_initsubtree->proc~tem_linecubeoverlap proc~tem_cylindercubeoverlap tem_cylinderCubeOverlap proc~tem_cylindercubeoverlap->proc~tem_linecubeoverlap proc~tem_shape_subtreefromgeominters tem_shape_subTreeFromGeomInters proc~tem_shape_subtreefromgeominters->proc~tem_cano_initsubtree proc~tem_shape_subtreefromgeominters->proc~tem_cylindercubeoverlap proc~tem_shape2subtree tem_shape2subTree proc~tem_shape2subtree->proc~tem_shape_subtreefromgeominters proc~tem_create_subtree_of tem_create_subTree_of proc~tem_create_subtree_of->proc~tem_shape2subtree

Source Code

  function tem_lineCubeOverlap( line, cube, pntIntersect ) result(overlap)
    ! ---------------------------------------------------------------------------!
    !> line segment to check for intersection
    type(tem_line_type), intent(in) :: line
    !> cube to intersect with
    type(tem_cube_type), intent(in) :: cube
    !> intersection point if there is intersection
    real(kind=rk), optional, intent(out) :: pntIntersect(3)
    logical :: overlap
    ! ---------------------------------------------------------------------------!
    real(kind=rk) :: proj
    real(kind=rk) :: loc_pntIntersect(3)
    ! ---------------------------------------------------------------------------!

    overlap = .false.
    !check whether line is intersect the cube by rayCubeOverlap test
    !then check whether intersected point is within the line segment
    if(rayCubeOverlap( line, cube, loc_pntIntersect )) then
      !project the intersected point on the line
      !and return true only if intersected point is
      !within line segment length
      !The point is inside the line segment if the
      !projected value is >= 0 and < 1.
      proj = dot_product(loc_pntIntersect-line%origin, line%vec) &
        &  / dot_product(line%vec, line%vec)
      overlap = (proj >= 0.0_rk) .and. (proj < 1.0_rk)
    endif

    if(present(pntIntersect))  pntIntersect = loc_pntIntersect

  end function tem_lineCubeOverlap