def plot(self): myplot = bp.Plotting((bp.PlottingPlotly())) myplot.plot_surface_3d(self.surfapprox.surfz, poles=False) myplot.plot_surface_3d(self.surfapprox2.surfz, poles=False) #myplot.scatter_3d(X, Y, Z) myplot.show() # view
def test_surface_intersection(self): control_points = [60, 60] sapp = SurfApprox(control_points) app = sapp.approx myplot = bp.Plotting((bp.PlottingPlotly())) myplot.plot_surface_3d(sapp.surfz, poles=False) #myplot.scatter_3d(app._xy_points[:, 0], app._xy_points[:, 1], app._z_points) myplot.show() # view
def test_surface_intersection(plane_coefficients1, control_points_1, length1): #plane_coefficients1 print(plane_coefficients1, control_points_1, length1) #plane_coefficients1 = np.array([-1, 1, -1, 7]) plane_coefficients2 = np.array([2, -1, -1, 3]) def cosx(x): return math.cos(3 * x) length2 = [5, 7] control_points_2 = [10, 11] samples = [200, 200] sapp2 = SurfApprox(plane_coefficients2, length2, samples, control_points_2, cosx) myplot = bp.Plotting((bp.PlottingPlotly())) myplot.plot_surface_3d(sapp2.surfz, poles=False) myplot.show() # view
def test_plot_3d(self): self.plotting_3d(bp.Plotting(bp.PlottingMatplot())) self.plotting_3d(bp.Plotting(bp.PlottingPlotly()))
def plot_extrude(self): #fig1 = plt.figure() #ax1 = fig1.gca(projection='3d') def function(x): return math.sin(x[0]*4) * math.cos(x[1] * 4) def function2(x): return math.cos(x[0]*4) * math.sin(x[1] * 4) def function3(x): return (-x[0] + x[1] + 4 + 3 + math.cos(3 * x[0])) def function4(x): return (2 * x[0] - x[1] + 3 + math.cos(3 * x[0])) u1_int = 4 v1_int = 4 u2_int = 4 v2_int = 4 u_basis = bs.SplineBasis.make_equidistant(2, u1_int) #10 v_basis = bs.SplineBasis.make_equidistant(2, v1_int) #15 u2_basis = bs.SplineBasis.make_equidistant(2, u2_int) #10 v2_basis = bs.SplineBasis.make_equidistant(2, v2_int) #15 poles = bs.make_function_grid(function, u1_int + 2, v1_int + 2) #12, 17 surface_extrude = bs.Surface((u_basis, v_basis), poles) myplot = bp.Plotting((bp.PlottingPlotly())) #myplot.plot_surface_3d(surface_extrude, poles = False) poles2 = bs.make_function_grid(function2, u2_int + 2, v2_int + 2) #12, 17 surface_extrude2 = bs.Surface((u2_basis, v2_basis), poles2) #myplot.plot_surface_3d(surface_extrude2, poles=False) m = 100 fc = np.zeros([m * m, 3]) fc2 = np.empty([m * m, 3]) a = 5 b = 7 #print(fc) for i in range(m): for j in range(m): #print([i,j]) x = i / m * a y = j / m * b z = function3([x, y]) z2 = function4([x, y]) fc[i + j * m, :] = [x, y, z] fc2[i + j * m, :] = [x, y, z2] #print(fc) #gs = bs.GridSurface(fc.reshape(-1, 3)) #gs.transform(xy_mat, z_mat) #approx = bsa.SurfaceApprox.approx_from_grid_surface(gs) approx = bsa.SurfaceApprox(fc) approx2 = bsa.SurfaceApprox(fc2) surfz = approx.compute_approximation(nuv=np.array([11, 26])) surfz2 = approx2.compute_approximation(nuv=np.array([20, 16])) #surfz = approx.compute_approximation(nuv=np.array([3, 5])) #surfz2 = approx2.compute_approximation(nuv=np.array([2, 4])) surfzf = surfz.make_full_surface() surfzf2 = surfz2.make_full_surface() myplot.plot_surface_3d(surfzf, poles=False) myplot.plot_surface_3d(surfzf2, poles=False) #return surface_extrude, surface_extrude2, myplot return surfzf, surfzf2, myplot