Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the circle area weight #177

Open
shawnLiao23 opened this issue Aug 3, 2024 · 0 comments
Open

the circle area weight #177

shawnLiao23 opened this issue Aug 3, 2024 · 0 comments

Comments

@shawnLiao23
Copy link

shawnLiao23 commented Aug 3, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant