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
Aspect-preserving mapping from projected 2D coordinates into the data window. A single shared pixel scale keeps the projected box from being independently stretched on x and y, so the cube stays tilted with the correct proportions in every backend.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=wp), | public | :: | proj_cx | = | 0.0_wp | ||
| real(kind=wp), | public | :: | proj_cy | = | 0.0_wp | ||
| real(kind=wp), | public | :: | data_cx | = | 0.0_wp | ||
| real(kind=wp), | public | :: | data_cy | = | 0.0_wp | ||
| real(kind=wp), | public | :: | scale_x | = | 1.0_wp | ||
| real(kind=wp), | public | :: | scale_y | = | 1.0_wp |
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 |
Project 3D coordinates to 2D using orthographic projection.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=wp), | intent(in), | contiguous | :: | x3d(:) | ||
| real(kind=wp), | intent(in), | contiguous | :: | y3d(:) | ||
| real(kind=wp), | intent(in), | contiguous | :: | 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)) | |||
| real(kind=wp), | intent(out), | optional | :: | depth(size(x3d)) |
Build the aspect-preserving projection map for one 3D axes box.
| 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(in) | :: | x_min | |||
| real(kind=wp), | intent(in) | :: | x_max | |||
| real(kind=wp), | intent(in) | :: | y_min | |||
| real(kind=wp), | intent(in) | :: | y_max | |||
| real(kind=wp), | intent(in) | :: | width_px_per_data | |||
| real(kind=wp), | intent(in) | :: | height_px_per_data | |||
| type(projected_axes_map_t), | intent(out) | :: | map |
Apply an aspect-preserving projection map to one projected point.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(projected_axes_map_t), | intent(in) | :: | map | |||
| real(kind=wp), | intent(in) | :: | x_proj | |||
| real(kind=wp), | intent(in) | :: | y_proj | |||
| real(kind=wp), | intent(out) | :: | x_out | |||
| real(kind=wp), | intent(out) | :: | y_out |