home Subroutine

private subroutine home(self, aspect, eye, center, up)

The default camera (eye, center, up in view-frame coordinates) for a viewport of aspect ratio aspect (width / height): OpenFrames' resetView.

Type Bound

View

Arguments

Type IntentOptional Attributes Name
class(View), intent(in) :: self
real(kind=wp), intent(in) :: aspect

viewport width / height

real(kind=wp), intent(out) :: eye(3)

the default camera (view-frame coordinates)

real(kind=wp), intent(out) :: center(3)

the default camera (view-frame coordinates)

real(kind=wp), intent(out) :: up(3)

the default camera (view-frame coordinates)


Calls

proc~~home~~CallsGraph proc~home View%home proc~bound ReferenceFrame%bound proc~home->proc~bound proc~frame_to_root frame_to_root proc~home->proc~frame_to_root proc~world_to_view View%world_to_view proc~home->proc~world_to_view proc~rigid_inverse rigid_inverse proc~frame_to_root->proc~rigid_inverse proc~world_matrix ReferenceFrame%world_matrix proc~frame_to_root->proc~world_matrix proc~world_to_view->proc~frame_to_root proc~identity_matrix identity_matrix proc~world_to_view->proc~identity_matrix proc~quat_from_vectors quat_from_vectors proc~world_to_view->proc~quat_from_vectors proc~quat_to_matrix quat_to_matrix proc~world_to_view->proc~quat_to_matrix proc~world_to_view->proc~rigid_inverse proc~rotated rotated proc~world_to_view->proc~rotated proc~translation_matrix translation_matrix proc~world_to_view->proc~translation_matrix proc~cross cross proc~quat_from_vectors->proc~cross proc~quat_normalize quat_normalize proc~quat_from_vectors->proc~quat_normalize proc~translation_matrix->proc~identity_matrix proc~world_matrix->proc~world_matrix proc~local_matrix ReferenceFrame%local_matrix proc~world_matrix->proc~local_matrix proc~frame_matrix frame_matrix proc~local_matrix->proc~frame_matrix proc~frame_matrix->proc~quat_to_matrix

Called by

proc~~home~~CalledByGraph proc~home View%home proc~place_camera place_camera proc~place_camera->proc~home proc~frame WindowProxy%frame proc~frame->proc~place_camera proc~resize WindowProxy%resize proc~resize->proc~frame proc~run WindowProxy%run proc~run->proc~frame

Source Code

    subroutine home(self, aspect, eye, center, up)
        class(View), intent(in) :: self
        real(wp), intent(in) :: aspect      !! viewport width / height
        real(wp), intent(out) :: eye(3), center(3), up(3) !! the default camera (view-frame coordinates)
        real(wp) :: c(3), r, dist, half_fovy, half_fovx, m(4,4)
        if (norm2(self%default_up) /= 0.0_wp) then
            eye = self%default_eye
            center = self%default_center
            up = self%default_up
            return
        end if
        c = 0.0_wp
        r = 0.0_wp
        if (associated(self%frame)) then
            call self%frame%bound(c, r)
            m = matmul(self%world_to_view(), frame_to_root(self, self%frame))    ! frame to view frame
            c = matmul(m(1:3, 1:3), c) + m(1:3, 4)
        end if
        if (self%default_distance > 0.0_wp) then
            r = self%default_distance
        else if (r <= 0.0_wp) then
            r = 1.0_wp
        end if
        dist = 2.0_wp * r
        if (self%projection == PERSPECTIVE) then
            half_fovy = 0.5_wp * self%fovy * pi / 180.0_wp
            half_fovx = atan(aspect * tan(half_fovy))
            dist = r / sin(min(half_fovy, half_fovx))
        end if
        center = c
        eye = c + [0.0_wp, -dist, 0.0_wp]
        up = [0.0_wp, 0.0_wp, 1.0_wp]
    end subroutine home