Given 3D edge points How to generate mesh - python

I have a set of 3D edge points, and I want to create a surface. Because the points are 3D, I cannot use Delaunay triangulation. And I don't know how to use 3D B-Spline surface and how to convert it to mesh. Is there any python/c++ lib or any algorithm for this problem?

Related

How do you find the coordinates of a plane with a minimized distance strictly above a 3D dataset (python)?

As the title states, I need to make a plane above a 3D dataset in Python. There should be no data points above such plane, and the distances between the plane and the dataset should be optimized such that the plane somehow generalizes the whole data.
this is the 3d surface plot
(this is another example) the plane should look like this
I've been stuck for months on how to start/approach this problem. Should I start looking for the maximums in the data? Should I start on finding the peak in the middle and tamper around the possible slopes of the plane? Or are there other appropriate mathematical methods for this?
Thanks ahead.

Plotting a coastline on cartesian grid in matplotlib

I am making maps of meteorological data (x,y-coordinates in m) using matplotlib.pyplot.contourf(). I want to plot a coastline, but all the examples I find on internet use lat-lon data (with cartopy or basemap).
Is there a way (without transforming the data to a lat-lon grid) to plot a coastline on my cartesian grid? I know size of the grid, and its center's lat-lon coordinates.
I haven't tried anything but look for similar examples, which I could not find.
The solution is to use cartopy's gnomonic projection: https://scitools.org.uk/cartopy/docs/v0.15/crs/projections.html#gnomonic , e.g.
proj =ccrs.Gnomonic(central_latitude=0, central_longitude= 0)
The origin of the data need to be specified (in lat-lon), and it expects the data coordinates to be distance in meters from that origin. Then, the normal cartopy features (like coastlines) work as usual.

Rotating a light cone to a given axis

Suppose I have a cone of evenly distributed points starting at (0,0,0) and with its main axes along (0,0,1). I need to create a python script that rotates all points, so the cone is parallel to (1,1,1). What is the easiest way to to this using spherical coordinates?
For now, I've been transforming my spherical coordinates to cartesian ones, applying Rodrigue's formula and finally transforming the coordinates back again to spherical. But there should be an easier way, right?

How to export 3d delaunay triangle mesh with python?

I want to use scipy.spatial.delaunay get the triangle mesh from the 3d point cloud. And i use trimesh to save the triangle mesh as .ply form. But the result seems bad. All points play roles as vertices, so it works slowly and bad... how can i get a better mesh output with this delaunay method?
Code:
#pcd is 3d point cloud
tri = Delaunay(pcd)
#faces
f = tri.simplices
# Mesh
mesh = trimesh.Trimesh(vertices=pos_combine, faces=f)
# show mesh and export it
mesh.show()
mesh.export(file_obj="mesh.ply")
I write meshio for this. Just do
import meshio
meshio.Mesh(pcd, {"triangles": tri.simplices}).write("out.ply")
should do the job.

Using pcolor or pcolormesh with data in mesh center (polar plot)

I want to make a polar plot of a temperature field.
I used pcolor/pcolormesh but both of them make an interpolation between each corners of the mesh.
Thus, I am looking for a simple way to center the meshes on the center of my data with a mesh color corresponding to the data only in the center of these meshes.
Finally, It would be very nice if I could have polar meshes and not rectangular meshes.
Thanks for your help.

Categories