quat_to_matrix Function

public pure function quat_to_matrix(q) result(m)

The 3x3 rotation matrix of the unit quaternion q (columns: the rotated axes).

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: q(4)

unit quaternion [x, y, z, w]

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


Called by

proc~~quat_to_matrix~~CalledByGraph proc~quat_to_matrix quat_to_matrix proc~apply_attitude apply_attitude proc~apply_attitude->proc~quat_to_matrix proc~apply_name_attitude apply_name_attitude proc~apply_name_attitude->proc~quat_to_matrix proc~camera_between camera_between proc~camera_between->proc~quat_to_matrix proc~frame_matrix frame_matrix proc~frame_matrix->proc~quat_to_matrix proc~sphere_pick Sphere%sphere_pick proc~sphere_pick->proc~quat_to_matrix proc~world_to_view View%world_to_view proc~world_to_view->proc~quat_to_matrix proc~frame_to_root frame_to_root proc~world_to_view->proc~frame_to_root proc~fly fly proc~fly->proc~camera_between proc~fly->proc~world_to_view proc~get_camera WindowProxy%get_camera proc~get_camera->proc~world_to_view proc~home View%home proc~home->proc~world_to_view proc~home->proc~frame_to_root proc~local_matrix ReferenceFrame%local_matrix proc~local_matrix->proc~frame_matrix proc~local_matrix_at ReferenceFrame%local_matrix_at proc~local_matrix_at->proc~frame_matrix proc~followed_pose followed_pose proc~local_matrix_at->proc~followed_pose proc~make_line_node make_line_node proc~make_line_node->proc~apply_attitude proc~make_name_node make_name_node proc~make_name_node->proc~apply_name_attitude proc~make_star_node make_star_node proc~make_star_node->proc~apply_attitude proc~make_star_node->proc~make_name_node proc~make_texture_node make_texture_node proc~make_texture_node->proc~apply_attitude proc~model_frame_bound Model%model_frame_bound proc~model_frame_bound->proc~frame_matrix proc~place_camera place_camera proc~place_camera->proc~world_to_view proc~place_camera->proc~fly proc~place_camera->proc~home proc~set_attitude~2 SkySphere%set_attitude proc~set_attitude~2->proc~apply_attitude proc~set_attitude~2->proc~apply_name_attitude proc~set_camera WindowProxy%set_camera proc~set_camera->proc~world_to_view proc~track_view track_view proc~track_view->proc~world_to_view proc~update_model_transform update_model_transform proc~update_model_transform->proc~frame_matrix proc~update_sphere_transform update_sphere_transform proc~update_sphere_transform->proc~frame_matrix proc~frame WindowProxy%frame proc~frame->proc~place_camera proc~frame->proc~track_view proc~sync ReferenceFrame%sync proc~frame->proc~sync proc~realize ReferenceFrame%realize proc~frame->proc~realize proc~dispatch_events dispatch_events proc~frame->proc~dispatch_events proc~model_build_contents Model%model_build_contents proc~model_build_contents->proc~update_model_transform proc~model_pick Model%model_pick proc~model_pick->proc~model_frame_bound proc~node~2 SkySphere%node proc~node~2->proc~make_line_node proc~node~2->proc~make_star_node proc~node~2->proc~make_texture_node proc~place place proc~place->proc~local_matrix proc~world_matrix ReferenceFrame%world_matrix proc~place->proc~world_matrix proc~set_constellations SkySphere%set_constellations proc~set_constellations->proc~make_line_node proc~set_model_attitude Model%set_model_attitude proc~set_model_attitude->proc~update_model_transform proc~set_model_pivot Model%set_model_pivot proc~set_model_pivot->proc~update_model_transform proc~set_model_position Model%set_model_position proc~set_model_position->proc~update_model_transform proc~set_model_scale Model%set_model_scale proc~set_model_scale->proc~update_model_transform proc~set_radius Sphere%set_radius proc~set_radius->proc~update_sphere_transform proc~set_sphere_attitude Sphere%set_sphere_attitude proc~set_sphere_attitude->proc~update_sphere_transform proc~set_sphere_position Sphere%set_sphere_position proc~set_sphere_position->proc~update_sphere_transform proc~set_sphere_scale Sphere%set_sphere_scale proc~set_sphere_scale->proc~update_sphere_transform proc~set_star_data SkySphere%set_star_data proc~set_star_data->proc~make_star_node proc~set_star_names SkySphere%set_star_names proc~set_star_names->proc~make_name_node proc~set_texture_map~2 SkySphere%set_texture_map proc~set_texture_map~2->proc~make_texture_node proc~sphere_build_contents Sphere%sphere_build_contents proc~sphere_build_contents->proc~update_sphere_transform proc~sync->proc~local_matrix proc~sync->proc~sync proc~time_drag TimeHandle%time_drag proc~time_drag->proc~local_matrix proc~time_drag->proc~world_matrix proc~view_camera view_camera proc~view_camera->proc~get_camera proc~window_pick WindowProxy%window_pick proc~window_pick->proc~local_matrix proc~window_pick->proc~view_camera proc~world_matrix->proc~local_matrix proc~world_matrix->proc~world_matrix proc~world_matrix_at ReferenceFrame%world_matrix_at proc~world_matrix_at->proc~local_matrix_at proc~world_matrix_at->proc~world_matrix_at proc~cursor_ray WindowProxy%cursor_ray proc~cursor_ray->proc~view_camera proc~data_to_shown data_to_shown proc~data_to_shown->proc~world_matrix_at proc~drag DragHandle%drag proc~drag->proc~world_matrix proc~fm_update FrameManager%fm_update proc~fm_update->proc~sync proc~update ReferenceFrame%update proc~fm_update->proc~update proc~followed_pose->proc~world_matrix_at proc~frame_to_root->proc~world_matrix proc~grab DragHandle%grab proc~grab->proc~world_matrix proc~hover_handle hover_handle proc~hover_handle->proc~window_pick proc~position_of ReferenceFrame%position_of proc~position_of->proc~world_matrix proc~realize->proc~sync proc~realize->proc~realize proc~resize WindowProxy%resize proc~resize->proc~frame proc~run WindowProxy%run proc~run->proc~frame proc~screen_position WindowProxy%screen_position proc~screen_position->proc~view_camera proc~set_sky WindowProxy%set_sky proc~set_sky->proc~node~2 proc~shadow_late_update ShadowCones%shadow_late_update proc~shadow_late_update->proc~place proc~add_child ReferenceFrame%add_child proc~add_child->proc~realize proc~dispatch_event dispatch_event proc~dispatch_event->proc~hover_handle proc~drag_handle drag_handle proc~dispatch_event->proc~drag_handle proc~grab_handle grab_handle proc~dispatch_event->proc~grab_handle proc~release_handle release_handle proc~dispatch_event->proc~release_handle proc~drag_handle->proc~cursor_ray proc~drag_handle->proc~drag proc~grab_handle->proc~cursor_ray proc~grab_handle->proc~grab proc~release_handle->proc~hover_handle proc~to_shown to_shown proc~to_shown->proc~data_to_shown proc~update->proc~followed_pose proc~art_point_between art_point_between proc~art_point_between->proc~to_shown proc~dispatch_events->proc~dispatch_event proc~drawable_update DrawableTrajectory%drawable_update proc~drawable_update->proc~update proc~sphere_update Sphere%sphere_update proc~sphere_update->proc~update proc~terrain_update TerrainBody%terrain_update proc~terrain_update->proc~update proc~to_shown_at to_shown_at proc~to_shown_at->proc~to_shown proc~art_point art_point proc~art_point->proc~to_shown_at proc~art_points art_points proc~art_points->proc~to_shown_at proc~intermediates_by_time intermediates_by_time proc~intermediates_by_time->proc~art_point_between proc~marker_point marker_point proc~marker_point->proc~to_shown_at proc~marker_point->proc~art_point proc~update_ribbon_tail RibbonArtist%update_ribbon_tail proc~update_ribbon_tail->proc~art_point_between proc~update_ribbon_tail->proc~art_point proc~update_tail CurveArtist%update_tail proc~update_tail->proc~art_point_between proc~update_tail->proc~art_point proc~write_segments write_segments proc~write_segments->proc~to_shown_at proc~add_intermediates add_intermediates proc~add_intermediates->proc~intermediates_by_time proc~intermediates_by_data intermediates_by_data proc~add_intermediates->proc~intermediates_by_data proc~intermediates_by_distance intermediates_by_distance proc~add_intermediates->proc~intermediates_by_distance proc~curve_pick curve_pick proc~curve_pick->proc~art_point proc~intermediates_by_data->proc~art_point proc~intermediates_by_distance->proc~art_point proc~marker_update MarkerArtist%marker_update proc~marker_update->proc~marker_point proc~marker_update->proc~add_intermediates proc~update_bounds update_bounds proc~marker_update->proc~update_bounds proc~segment_update SegmentArtist%segment_update proc~segment_update->proc~write_segments proc~update_bounds->proc~art_points proc~write_curve CurveArtist%write_curve proc~write_curve->proc~art_points proc~write_ribbon RibbonArtist%write_ribbon proc~write_ribbon->proc~art_points proc~drawable_pick DrawableTrajectory%drawable_pick proc~drawable_pick->proc~curve_pick

Source Code

    pure function quat_to_matrix(q) result(m)
        real(wp), intent(in) :: q(4)                    !! unit quaternion [x, y, z, w]
        real(wp) :: m(3,3)
        real(wp) :: x, y, z, w
        x = q(1); y = q(2); z = q(3); w = q(4)
        m(1,1) = 1.0_wp - 2.0_wp * (y*y + z*z)
        m(2,1) = 2.0_wp * (x*y + z*w)
        m(3,1) = 2.0_wp * (x*z - y*w)
        m(1,2) = 2.0_wp * (x*y - z*w)
        m(2,2) = 1.0_wp - 2.0_wp * (x*x + z*z)
        m(3,2) = 2.0_wp * (y*z + x*w)
        m(1,3) = 2.0_wp * (x*z + y*w)
        m(2,3) = 2.0_wp * (y*z - x*w)
        m(3,3) = 1.0_wp - 2.0_wp * (x*x + y*y)
    end function quat_to_matrix