A triangle's unit normal (counterclockwise: its front), or +z if it has no area.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in) | :: | a(3) |
the triangle's vertices |
||
| real(kind=wp), | intent(in) | :: | b(3) |
the triangle's vertices |
||
| real(kind=wp), | intent(in) | :: | c(3) |
the triangle's vertices |
pure function unit_normal(a, b, c) result(n) real(wp), intent(in) :: a(3), b(3), c(3) !! the triangle's vertices real(wp) :: n(3), len_ n = cross(b - a, c - a) len_ = norm2(n) if (len_ > 0.0_wp) then n = n / len_ else n = [0.0_wp, 0.0_wp, 1.0_wp] end if end function unit_normal