You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider, we have a thin rectangular shaped plane and a sphere. The sphere's pose is above the plane such that it intersects the plane. We remove the part of the sphere that lies above the plane.
Now, how do we deform the plane to show the bulge or "curved effect" caused by the sphere? I have managed to do the following(please see the figure and code). Since I am using convex hull, the plane is not bent like a smooth curved fashion. How can I achieve the curved effect?
Unfortunately, I cannot use python3 version of trimesh.
@mikedh It would be such a huge help, if you have any ideas on how to handle this. Thank you.
Hi, you may use shrinkwarping to do that. Represent the sphere as a distance function for all the vertices of the plane and project the vertices with a negative distance to the surface of the sphere.
Shrinkwarping is simple but it looks like it achieves what you want.
There exist more advanced deformers though (see As Rigid As Possible).
To my knowledge (?) trimesh does not implement them.
Great point yeah that looks like a good solution, I was thinking some quadratic function would probably look nice. My only note is you probably want to subdivide your plane a bunch (subdivide, subdivide_to_size) so any function is applied smooth-ish way, here it is just applying an offset exactly under the sphere:
import numpy as np
import trimesh
if __name__ == "__main__":
# start with a two triangle plane
plane = trimesh.Trimesh(
vertices=[[-3, -3, -3], [3, -3, -3], [3, 3, -3], [-3, 3, -3]],
faces=[[0, 1, 2], [0, 2, 3]],
)
# subdivide it a bunch of times
for _ in range(7):
plane = plane.subdivide()
# put a sphere in the middle
sphere_center = [0.0, 0.0, 0.0]
sphere_radius = 1.5
# you can offset just the pieces
polar_radius = np.linalg.norm(plane.vertices[:, :2], axis=1)
ok = polar_radius < sphere_radius
exact = np.zeros(len(plane.vertices))
exact[ok] = (sphere_radius**2 - polar_radius[ok] ** 2) ** 0.5
# just offset the vertices on the sphere
plane.vertices[:, 2] += exact
Consider, we have a thin rectangular shaped plane and a sphere. The sphere's pose is above the plane such that it intersects the plane. We remove the part of the sphere that lies above the plane.
Now, how do we deform the plane to show the bulge or "curved effect" caused by the sphere? I have managed to do the following(please see the figure and code). Since I am using convex hull, the plane is not bent like a smooth curved fashion. How can I achieve the curved effect?
Unfortunately, I cannot use python3 version of trimesh.
@mikedh It would be such a huge help, if you have any ideas on how to handle this. Thank you.
The text was updated successfully, but these errors were encountered: