def check_all_normals(self, interval=100) -> None: centroid = math.mean(self) scale = np.mean(self.nn_weights[:, 3]) normals = self.point_normals[:, ::interval]*scale pyplot.plot3d(*self[:, ::interval], '.', alpha=1, markersize=1) pyplot.quiver3d( *self[:, ::interval], *normals) pyplot.equal_aspect_3d_centered(centroid) pyplot.show()
def check_normals_n_at_a_time(self, interval=1000, n_normals=3) -> None: scale = np.mean(self.nn_weights[:, 3]) for i, (point, normal) in enumerate( zip(self.T, self.point_normals.T)): if i % interval == 0: normal = normal*scale I_nearest = self.nn_indices[i] # nn = self[:, I_nearest] # nn_normals = self.point_normals[I_nearest] pyplot.plot3d(*self, '.', alpha=1, markersize=1) pyplot.quiver3d(*point, *normal) pyplot.equal_aspect_3d_centered(point) pyplot.show()
x = (c + a * np.cos(theta)) * np.cos(phi) y = (c + a * np.cos(theta)) * np.sin(phi) z = a * np.sin(theta) xyz = np.array([x, y, z]) obj = cls(xyz, **kwargs) analytical = TorusSurfaceProperties( obj, a, c, theta, phi, external=kwargs.get('external', True) ) obj.analytical = analytical return obj if __name__ == "__main__": psurf = Ellipsoid.sunflower_spiral( n_pts=10000, a=2, leafsize=100, neighbours=150, external=False) # psurf = Cylinder.sunflower_spiral( # n_pts=10000, neighbours=12, external=False) # psurf = Torus.sunflower_spiral( # n_pts=50000, neighbours=300, external=False) psurf.plot_analytical_curvature() plt.show() psurf.compute_principle_curvatures(n_processors=10) psurf.check_normals_n_at_a_time(interval=500) psurf.plot_error() psurf.plot_analytical_curvature() psurf.plot_curvature() plt.show() print('done')
file = data_folder/'00000.vtk' pv_obj = pv.read(file) points = pv_obj.points.T test_points = points[:, ::20]*1000 # test_points = points*1000 psurf = Pointsurface( test_points, leafsize=100, neighbours=13, external=True) psurf.compute_all_normals() psurf.compute_principle_curvatures(n_processors=5) psurf if False: ii = 500 ids = psurf.nn_indices[ii] xx, yy = psurf.principle_directions[ii].T X, Y, Z = psurf.point_basis[ii].T pyplot.plot3d(*psurf, '.', alpha=0.5, markersize=2) pyplot.plot3d(*psurf[:, ii, None], 'go') pyplot.plot3d(*psurf[:, ids], 'ro') pyplot.quiver3d(*psurf[:, ii, None], *X[:, None], color='blue') pyplot.quiver3d(*psurf[:, ii, None], *Y[:, None], color='blue') pyplot.quiver3d(*psurf[:, ii, None], *Z[:, None], color='green') pyplot.quiver3d(*psurf[:, ii, None], *xx[:, None], color='red') pyplot.quiver3d(*psurf[:, ii, None], *yy[:, None], color='red') pyplot.equal_aspect_3d_centered(psurf[:, ii, None]) pyplot.show() # psurf.plot_curvature() # pyplot.show() # psurf.check_all_normals(interval=1) print('done')