fortplot_projection Module

3D to 2D projection module for rendering 3D plots in 2D backends

Based on matplotlib's implementation with default viewing angles: - azimuth: -60 degrees - elevation: 30 degrees
- distance: 10 units - perspective projection with focal_length = 1



Subroutines

public subroutine get_default_view_angles(azim, elev, dist)

Get default viewing angles matching matplotlib

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(out) :: azim
real(kind=wp), intent(out) :: elev
real(kind=wp), intent(out) :: dist

public subroutine create_projection_matrix(azim, elev, dist, proj_matrix)

Create 4x4 projection matrix for 3D to 2D transformation

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: azim
real(kind=wp), intent(in) :: elev
real(kind=wp), intent(in) :: dist
real(kind=wp), intent(out) :: proj_matrix(4,4)

public subroutine project_3d_to_2d(x3d, y3d, z3d, azim, elev, dist, x2d, y2d)

Project 3D coordinates to 2D using orthographic projection

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x3d(:)
real(kind=wp), intent(in) :: y3d(:)
real(kind=wp), intent(in) :: z3d(:)
real(kind=wp), intent(in) :: azim
real(kind=wp), intent(in) :: elev
real(kind=wp), intent(in) :: dist
real(kind=wp), intent(out) :: x2d(size(x3d))
real(kind=wp), intent(out) :: y2d(size(x3d))