'How to convert a 3D vertex list into meshgrids in Python

I'm looking for a way to convert the data of a 3d model (contained in an .obj file) into three different meshgrids, corresponding to the three x,y and z coordinates. To make the problem clearer I will give you an example: normally when someone wants to plot a function in Python with a surface he has to run the following code:

## example: plot a 3d unit sphere
##*******************************

import matplotlib.pyplot as plt
import numpy as np

theta, phi = np.linspace(0, 2*np.pi, 100), np.linspace(0, np.pi, 100)
T, P       = np.meshgrid(theta, phi)

x = np.cos(T)*np.sin(P)
y = np.sin(T)*np.sin(P)
z = np.cos(P)

fig = plt.figure()
ax  = fig.add_subplot(projection='3d')

ax.plot_surface(x, y, z)
plt.show()

In x,y and z are contained 2D matrices of shape=(100,100). This is the format I meant at the beginning of the question, saying that I need three meshgrids (corresponding to x,y and z). The only problem is that these three meshgrids must be created using the data contained in an .obj file. I already know how to extract the vertex list from the .obj file. So the problem becomes: how to convert the 3d vertex list into three meshgrids, as given above (namely corresponding to x,y and z). Do you have any ideas on what I could do?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source