solidellipsoidCubeOverlap Function

private function solidellipsoidCubeOverlap(me, cube) result(overlap)

This function checks intesection of solid cube and solid ellipsoid

This algorithm is taken from http://tog.acm.org/resources/GraphicsGems/gems/Boxellipsoid.c

Arguments

Type IntentOptional Attributes Name
type(tem_ellipsoid_type), intent(in) :: me

ellipsoid object

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

cube object

Return Value logical


Called by

proc~~solidellipsoidcubeoverlap~2~~CalledByGraph proc~solidellipsoidcubeoverlap~2 solidellipsoidCubeOverlap proc~tem_ellipsoidcubeoverlap~2 tem_ellipsoidCubeOverlap proc~tem_ellipsoidcubeoverlap~2->proc~solidellipsoidcubeoverlap~2

Contents


Source Code

  function solidellipsoidCubeOverlap(me, cube) result(overlap)
    ! --------------------------------------------------------------------------!
    !> ellipsoid object
    type(tem_ellipsoid_type), intent(in) :: me
    !> cube object
    type(tem_cube_type), intent(in) :: cube
    logical :: overlap !< return value
    ! --------------------------------------------------------------------------!
    ! local variables
    integer :: i
    real(kind=rk) :: dmin
    ! --------------------------------------------------------------------------!

    ! minimum distance
    dmin = 0.0_rk

    do i=1,3
      if ( me%origin(i) < cube%origin(i) ) then
        dmin = dmin + &
          &  ( me%origin(i) - cube%origin(i) )**2 / me%radius(i)**2
        ! dmin = dmin + ( me%origin(i) - cube%origin(i) )**2
      else if ( me%origin(i) > cube%endPnt(i) ) then
        dmin = dmin + &
          &  ( me%origin(i) - cube%endPnt(i) )**2 / me%radius(i)**2
        ! dmin = dmin +  ( me%origin(i) - cube%endPnt(i) )**2
      end if
    end do

    overlap = ( dmin <= 1.0_rk )

  end function solidellipsoidCubeOverlap