evaluate_box Function

private pure elemental function evaluate_box(this, pos) result(res)

Evaluation function for Box SDF.

Type Bound

box

Arguments

Type IntentOptional Attributes Name
class(box), intent(in) :: this
type(vector), intent(in) :: pos

vector position to evaluate SDF at

Return Value real(kind=wp)


Source Code

    pure elemental function evaluate_box(this, pos) result(res)
        !! Evaluation function for Box SDF.

        class(box),   intent(in) :: this
        !> vector position to evaluate SDF at
        type(vector), intent(in) :: pos

        real(kind=wp) :: res

        type(vector) :: p, q

        p = pos .dot. this%transform
        q = abs(p) - this%lengths
        res = length(max(q, 0._wp)) + min(max(q%x, max(q%y, q%z)), 0._wp)

    end function evaluate_box