Evaluation function for Capsule SDF.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(capsule), | intent(in) | :: | this | |||
type(vector), | intent(in) | :: | pos |
vector position to evaluate SDF at |
pure elemental function evaluate_capsule(this, pos) result(res) !! Evaluation function for Capsule SDF. use utils, only : clamp class(capsule), intent(in) :: this !> vector position to evaluate SDF at type(vector), intent(in) :: pos real(kind=wp) :: res type(vector) :: pa, ba, p real(kind=wp) :: h p = pos .dot. this%transform pa = p - this%a ba = this%b - this%a h = clamp((pa .dot. ba) / (ba .dot. ba), 0._wp, 1._wp) res = length(pa - ba*h) - this%r end function evaluate_capsule