Orthogonal Projection
I can use the proj_type='ortho'
argument to get an isometric projection which will use the following projection matrix:
def _ortho_transformation(zfront, zback):
# note: w component in the resulting vector will be (zback-zfront), not 1
a = -(zfront + zback)
b = -(zfront - zback)
proj_matrix = np.array([[2, 0, 0, 0],
[0, 2, 0, 0],
[0, 0, -2, 0],
[0, 0, a, b]])
return proj_matrix
proj3d.persp_transformation = _ortho_transformation
Oblique Cabinet Projection
Unfortunately I'm struggeling to obtain a Cabinet projection where the x and y axis are horizontal/vertical:
Looking into how a projection matrix would be defined in OpenGL led me to the following code, which results in a very distorted projection:
def _oblique_cabinet_transformation(_, __):
angle_degrees = 45
scale = 1.0
angle_rad = np.radians(angle_degrees)
shear_x = -np.cos(angle_rad)
shear_y = np.sin(angle_rad)
proj_matrix = np.array([[1, 0, shear_x * scale, 0],
[0, 1, shear_y * scale, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]])
return proj_matrix
proj3d.persp_transformation = _oblique_cabinet_transformation
This is somewhat expected, as the orthogonal opengl exampe already uses a different transformation matrix than matplotlib. What transformation matrix format is this and how do I obtain the desired perspective?