Bezier 曲面 (Python)
2022/1/11 17:05:48
本文主要是介绍Bezier 曲面 (Python),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import numpy as np from matplotlib import pyplot as plt import random import math from mpl_toolkits.mplot3d import Axes3D def getBezierInterp(p, t): if len(p) == 1: return p[0] return getBezierInterp([p[i]*(1-t) + p[i+1]*t for i in range(len(p)-1)], t) control_points = np.array([[np.array([i, j, random.random()]) for j in range(4)]for i in range(4)]) div = 20 xs = np.array([[0. for i in range(div)] for j in range(div)]) ys = np.array([[0. for i in range(div)] for j in range(div)]) zs = np.array([[0. for i in range(div)] for j in range(div)]) for i in range(div): t = i / div q = [getBezierInterp(control_points[j], t) for j in range(4)] for j in range(div): tt = j /div qq = getBezierInterp(q, tt) xs[i][j] = qq[0] ys[i][j] = qq[1] zs[i][j] = qq[2] fig = plt.figure(1, figsize=(6, 6)) ax = fig.add_subplot(1, 1, 1, projection='3d') ax.set_top_view() ax.plot_surface(xs, ys, zs, rstride=1, cstride=1, cmap='jet') plt.show()
这篇关于Bezier 曲面 (Python)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-21Python编程基础教程
- 2024-11-20Python编程基础与实践
- 2024-11-20Python编程基础与高级应用
- 2024-11-19Python 基础编程教程
- 2024-11-19Python基础入门教程
- 2024-11-17在FastAPI项目中添加一个生产级别的数据库——本地环境搭建指南
- 2024-11-16`PyMuPDF4LLM`:提取PDF数据的神器
- 2024-11-16四种数据科学Web界面框架快速对比:Rio、Reflex、Streamlit和Plotly Dash
- 2024-11-14获取参数学习:Python编程入门教程
- 2024-11-14Python编程基础入门