I am very interested in figuring out a way to describe a mesh with a function instead of triangles. This is because having a continues amount of points and normals would be very beneficial for the application I am building. However I haven't been able to figure out how it works.
The mesh I have to describe varies in shape each time the application is restarted as it is reconstructed directly from live captured depth images, however the overall shape of the mesh will be approximately the same.
This is the mesh of the mesh in case that makes it easier:
I have looked into scipy and numpy function but in all cases it seems like I provide x and y data and then I get some z value accordingly, but since I already have x, y and z values I just want to make some sort of surface fit estimations.
Any help would be much appreciated.
EDIT: With the help from @stef I found the function CloughTocher2DInterpolator, and with that I created this:
I¨m not sure if this is a good fit or not. So if someone have some suggestions please let me know. The code I use to do this was the following:
import open3d as o3d
import numpy as np
from scipy.interpolate import CloughTocher2DInterpolator
import matplotlib.pyplot as plt
mesh = o3d.io.read_triangle_mesh("../meshPath")
pcd = mesh.sample_points_uniformly(number_of_points=2500)
o3d.visualization.draw_geometries([pcd])
points = np.asarray(pcd.points)
x = points[:,0]
y = points[:,1]
z = points[:,2]
X = np.linspace(min(x), max(x))
Y = np.linspace(min(y), max(y))
X, Y = np.meshgrid(X, Y) # 2D grid for interpolation
interp = CloughTocher2DInterpolator(list(zip(x, y)), z, fill_value=-1.35)
Z = interp(X, Y)
#value = interp.__call__([1, 1])
fig = plt.figure()
ax = plt.axes(projection='3d')
#ax.contour3D(X, Y, Z, 75, cmap='prism')
#ax.plot_trisurf(x, y, z, cmap='viridis', edgecolor='none')
#ax.plot_wireframe(X, Y, Z, color='black')
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='viridis', edgecolor='none')
ax.set_title('surface')
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.show()
I can plot the surface with wireframes, contour plot and so on and they all seem to look good, beside the spikes on the left side.