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
import os
from geomdl import NURBS
from geomdl import construct
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import os
from geomdl import NURBS
from geomdl import construct
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
控制点数据
ctrlpts = [
[2.0, 0.0, 0.0,1.0], [0.0, 0.0, 0.0,1.0],
[2.0, 2.0, 0.0, np.sqrt(2)/2], [0.0, 0.0, 0.0, 1.0],
[0.0, 2.0, 0.0,1.0], [0.0, 0.0, 0.0,1.0],
[-2.0, 2.0, 0.0, np.sqrt(2)/2], [0.0, 0.0, 0.0, 1.0],
[-2.0, 0.0, 0.0,1.0], [0.0, 0.0, 0.0,1.0],
[-2.0, -2.0, 0.0, np.sqrt(2)/2], [0.0, 0.0, 0.0, 1.0],
[0.0, -2.0, 0.0,1.0], [0.0, 0.0, 0.0,1.0],
[2.0, -2.0, 0.0, np.sqrt(2)/2], [0.0, 0.0, 0.0, 1.0],
[2.0, 0.0, 0.0,1.0], [0.0, 0.0, 0.0,1.0]
]
创建NURBS曲面实例
surf = NURBS.Surface()
设置度数
surf.degree_u = 2
surf.degree_v = 1
设置控制点
surf.set_ctrlpts(ctrlpts, 9, 2)
设置结点向量
surf.knotvector_u = [0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 4]
surf.knotvector_v = [0, 0, 1, 1]
评估表面
surf.evaluate()
获取评估点
evalpts = np.array(surf.evalpts)
x = evalpts[:, 0]
y = evalpts[:, 1]
z = evalpts[:, 2]
绘制曲面
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_trisurf(x, y, z, cmap='viridis')
设置轴标签
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.set_title('NURBS Surface Plot')
显示图形
plt.show()
this code can not generate the circle how can I create a circle area or in other words disk
The text was updated successfully, but these errors were encountered: