place Subroutine

private subroutine place(self)

Move the shadow to the body's center (in the parent's coordinates) with its +z axis away from the light, and reshape the cones if the radii, the distance or the length set changed.

Arguments

Type IntentOptional Attributes Name
type(ShadowCones), intent(inout) :: self

Calls

proc~~place~~CallsGraph proc~place place proc~body_radius ShadowCones%body_radius proc~place->proc~body_radius proc~light_radius ShadowCones%light_radius proc~place->proc~light_radius proc~local_matrix ReferenceFrame%local_matrix proc~place->proc~local_matrix proc~quat_from_vectors quat_from_vectors proc~place->proc~quat_from_vectors proc~rigid_inverse rigid_inverse proc~place->proc~rigid_inverse proc~set_attitude ReferenceFrame%set_attitude proc~place->proc~set_attitude proc~set_position~2 ReferenceFrame%set_position proc~place->proc~set_position~2 proc~shape_regions shape_regions proc~place->proc~shape_regions proc~world_matrix ReferenceFrame%world_matrix proc~place->proc~world_matrix proc~frame_radius frame_radius proc~body_radius->proc~frame_radius proc~light_radius->proc~frame_radius proc~frame_matrix frame_matrix proc~local_matrix->proc~frame_matrix proc~cross cross proc~quat_from_vectors->proc~cross proc~quat_normalize quat_normalize proc~quat_from_vectors->proc~quat_normalize proc~next_motion_stamp next_motion_stamp proc~set_attitude->proc~next_motion_stamp proc~set_attitude->proc~quat_normalize proc~set_position~2->proc~next_motion_stamp proc~write_region write_region proc~shape_regions->proc~write_region proc~world_matrix->proc~local_matrix proc~world_matrix->proc~world_matrix proc~quat_to_matrix quat_to_matrix proc~frame_matrix->proc~quat_to_matrix body_radius body_radius proc~frame_radius->body_radius radii radii proc~frame_radius->radii interface~vkf_mesh_vertices_changed vkf_mesh_vertices_changed proc~write_region->interface~vkf_mesh_vertices_changed interface~vkf_switch_set vkf_switch_set proc~write_region->interface~vkf_switch_set proc~check_status check_status proc~write_region->proc~check_status proc~mesh_arrays mesh_arrays proc~write_region->proc~mesh_arrays interface~vkf_mesh_array vkf_mesh_array proc~mesh_arrays->interface~vkf_mesh_array

Called by

proc~~place~~CalledByGraph proc~place place proc~shadow_late_update ShadowCones%shadow_late_update proc~shadow_late_update->proc~place

Source Code

    subroutine place(self)
        type(ShadowCones), intent(inout) :: self
        real(wp) :: to_parent(4,4), m(4,4), b(3), s(3), u(3), d, now(4)
        ! the body's and the light's centers in the parent's coordinates
        to_parent = rigid_inverse(matmul(self%world_matrix(), rigid_inverse(self%local_matrix())))
        m = matmul(to_parent, self%body_%world_matrix())
        b = m(1:3, 4)
        m = matmul(to_parent, self%light_%world_matrix())
        s = m(1:3, 4)
        u = b - s
        d = norm2(u)
        self%distance_ = d
        call self%set_position(b)
        if (d > 0.0_wp) call self%set_attitude(quat_from_vectors([0.0_wp, 0.0_wp, 1.0_wp], u / d))
        now = [self%body_radius(), self%light_radius(), d, self%length_]
        if (all(now == self%shaped)) return
        self%shaped = now
        call shape_regions(self, now(1), now(2), d)
    end subroutine place