update_arrow Subroutine

private subroutine update_arrow(self)

The shaft and head placed for the vector (hidden if it is 0).

Arguments

Type IntentOptional Attributes Name
class(VectorHandle), intent(inout) :: self

Calls

proc~~update_arrow~~CallsGraph proc~update_arrow update_arrow interface~vkf_switch_set vkf_switch_set proc~update_arrow->interface~vkf_switch_set interface~vkf_transform_set_matrix vkf_transform_set_matrix proc~update_arrow->interface~vkf_transform_set_matrix proc~arrow_sizes arrow_sizes proc~update_arrow->proc~arrow_sizes proc~check_status check_status proc~update_arrow->proc~check_status proc~cross cross proc~update_arrow->proc~cross proc~tip VectorHandle%tip proc~update_arrow->proc~tip proc~arrow_sizes->proc~tip

Called by

proc~~update_arrow~~CalledByGraph proc~update_arrow update_arrow proc~set_display_scale VectorHandle%set_display_scale proc~set_display_scale->proc~update_arrow proc~set_head_size VectorHandle%set_head_size proc~set_head_size->proc~update_arrow proc~set_vector VectorHandle%set_vector proc~set_vector->proc~update_arrow proc~vector_build_contents VectorHandle%vector_build_contents proc~vector_build_contents->proc~update_arrow proc~vector_move_handle_point VectorHandle%vector_move_handle_point proc~vector_move_handle_point->proc~set_vector

Source Code

    subroutine update_arrow(self)
        class(VectorHandle), intent(inout) :: self
        real(wp) :: len, head_len, head_radius, u(3), a(3), b(3), m(4,4)
        if (.not. c_associated(self%switch)) return
        call arrow_sizes(self, len, head_len, head_radius)
        call check_status(vkf_switch_set(self%switch, merge(1_c_int, 0_c_int, len > 0.0_wp)))
        if (len <= 0.0_wp) return
        u = self%tip() / len
        a = cross(u, [1.0_wp, 0.0_wp, 0.0_wp])
        if (norm2(a) < 1.0e-6_wp) a = cross(u, [0.0_wp, 1.0_wp, 0.0_wp])
        a = a / norm2(a)
        b = cross(u, a)                                     ! (a, b, u right-handed)
        m = 0.0_wp
        m(4, 4) = 1.0_wp
        m(1:3, 1) = 0.4_wp * head_radius * a                ! the shaft: 0.4 of the head's radius
        m(1:3, 2) = 0.4_wp * head_radius * b
        m(1:3, 3) = (len - head_len) * u
        call check_status(vkf_transform_set_matrix(self%shaft, m))
        m(1:3, 1) = head_radius * a
        m(1:3, 2) = head_radius * b
        m(1:3, 3) = head_len * u
        m(1:3, 4) = (len - head_len) * u
        call check_status(vkf_transform_set_matrix(self%head, m))
    end subroutine update_arrow