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
Get default viewing angles matching matplotlib
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=wp), | intent(out) | :: | azim | |||
real(kind=wp), | intent(out) | :: | elev | |||
real(kind=wp), | intent(out) | :: | dist |
Create 4x4 projection matrix for 3D to 2D transformation
Type | Intent | Optional | 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) |
Project 3D coordinates to 2D using orthographic projection
Type | Intent | Optional | 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)) |