unit_normal Function

private pure function unit_normal(a, b, c) result(n)

A triangle's unit normal (counterclockwise: its front), or +z if it has no area.

Arguments

Type IntentOptional 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

Return Value real(kind=wp), (3)


Calls

proc~~unit_normal~~CallsGraph proc~unit_normal unit_normal proc~cross cross proc~unit_normal->proc~cross

Called by

proc~~unit_normal~~CalledByGraph proc~unit_normal unit_normal proc~make_polyhedron make_polyhedron proc~make_polyhedron->proc~unit_normal proc~poly_build_contents Polyhedron%poly_build_contents proc~poly_build_contents->proc~make_polyhedron proc~poly_set_draw_mode Polyhedron%poly_set_draw_mode proc~poly_set_draw_mode->proc~make_polyhedron proc~poly_set_line_color Polyhedron%poly_set_line_color proc~poly_set_line_color->proc~make_polyhedron proc~poly_set_line_width Polyhedron%poly_set_line_width proc~poly_set_line_width->proc~make_polyhedron proc~poly_set_opacity Polyhedron%poly_set_opacity proc~poly_set_opacity->proc~make_polyhedron proc~remove_vertex_colors Polyhedron%remove_vertex_colors proc~remove_vertex_colors->proc~make_polyhedron proc~set_edges Polyhedron%set_edges proc~set_edges->proc~make_polyhedron proc~set_face_color Polyhedron%set_face_color proc~set_face_color->proc~make_polyhedron proc~set_faces Polyhedron%set_faces proc~set_faces->proc~make_polyhedron proc~set_grid Polyhedron%set_grid proc~set_grid->proc~make_polyhedron proc~set_lit Polyhedron%set_lit proc~set_lit->proc~make_polyhedron proc~set_point_color Polyhedron%set_point_color proc~set_point_color->proc~make_polyhedron proc~set_point_size Polyhedron%set_point_size proc~set_point_size->proc~make_polyhedron proc~set_smooth Polyhedron%set_smooth proc~set_smooth->proc~make_polyhedron proc~set_triangles Polyhedron%set_triangles proc~set_triangles->proc~make_polyhedron proc~set_two_sided Polyhedron%set_two_sided proc~set_two_sided->proc~make_polyhedron proc~set_vertex_colors Polyhedron%set_vertex_colors proc~set_vertex_colors->proc~make_polyhedron proc~set_vertices Polyhedron%set_vertices proc~set_vertices->proc~make_polyhedron

Source Code

    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