博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
数学图形之贝塞尔(Bézier)曲面
阅读量:5111 次
发布时间:2019-06-13

本文共 3102 字,大约阅读时间需要 10 分钟。

前面章节中讲了,而贝塞尔曲面是对其多一个维度的扩展.其公式依然是曲线的公式:

\mathbf{B}(t)=\mathbf{P}_0(1-t)^3+3\mathbf{P}_1t(1-t)^2+3\mathbf{P}_2t^2(1-t)+\mathbf{P}_3t^3 \mbox{ , } t \in [0,1]

而之所以由曲线变成曲面,是将顶点横向连了再纵向连.

很多计算机图形学的教程都会有贝塞尔曲面的DEMO.而这里,我依然是使用我制定的脚本代码生成贝塞尔曲面.代码中的控制顶点坐标为随机数生成,所以每次生成的曲面图形都不一样.

相关软件参见:,使用自己定义语法的脚本代码生成数学图形.该软件免费开源.QQ交流群: 367752815

二次贝塞尔曲面:

需要生成3*3个控制顶点

vertices = D1:100 D2:100u = from 0 to 1 D1v = from 0 to 1 D2ax0 = rand2(-10, 10)ay0 = rand2(-10, 10)az0 = rand2(-10, 10)bx0 = rand2(-10, 10)by0 = rand2(-10, 10)bz0 = rand2(-10, 10)cx0 = rand2(-10, 10)cy0 = rand2(-10, 10)cz0 = rand2(-10, 10)ax1 = rand2(-10, 10)ay1 = rand2(-10, 10)az1 = rand2(-10, 10)bx1 = rand2(-10, 10)by1 = rand2(-10, 10)bz1 = rand2(-10, 10)cx1 = rand2(-10, 10)cy1 = rand2(-10, 10)cz1 = rand2(-10, 10)ax2 = rand2(-10, 10)ay2 = rand2(-10, 10)az2 = rand2(-10, 10)bx2 = rand2(-10, 10)by2 = rand2(-10, 10)bz2 = rand2(-10, 10)cx2 = rand2(-10, 10)cy2 = rand2(-10, 10)cz2 = rand2(-10, 10)ax3 = rand2(-10, 10)ay3 = rand2(-10, 10)az3 = rand2(-10, 10)bx3 = rand2(-10, 10)by3 = rand2(-10, 10)bz3 = rand2(-10, 10)cx3 = rand2(-10, 10)cy3 = rand2(-10, 10)cz3 = rand2(-10, 10)u1 = (1-u)*(1-u)u2 = 2*(1-u)*u  u3 = u*uax = u1*ax0+u2*ax1+u3*ax2ay = u1*ay0+u2*ay1+u3*ay2az = u1*az0+u2*az1+u3*az2bx = u1*bx0+u2*bx1+u3*bx2by = u1*by0+u2*by1+u3*by2bz = u1*bz0+u2*bz1+u3*bz2cx = u1*cx0+u2*cx1+u3*cx2cy = u1*cy0+u2*cy1+u3*cy2cz = u1*cz0+u2*cz1+u3*cz2v1 = (1-v)*(1-v)v2 = 2*(1-v)*v  v3 = v*vx = v1*ax+v2*bx+v3*cxy = v1*ay+v2*by+v3*cyz = v1*az+v2*bz+v3*czu = u*10v = v*10

三次贝塞尔曲面:

需要生成4*4个控制顶点

vertices = D1:100 D2:100u = from 0 to 1 D1v = from 0 to 1 D2ax0 = rand2(-10, 10)ay0 = rand2(-10, 10)az0 = rand2(-10, 10)bx0 = rand2(-10, 10)by0 = rand2(-10, 10)bz0 = rand2(-10, 10)cx0 = rand2(-10, 10)cy0 = rand2(-10, 10)cz0 = rand2(-10, 10)dx0 = rand2(-10, 10)dy0 = rand2(-10, 10)dz0 = rand2(-10, 10)ax1 = rand2(-10, 10)ay1 = rand2(-10, 10)az1 = rand2(-10, 10)bx1 = rand2(-10, 10)by1 = rand2(-10, 10)bz1 = rand2(-10, 10)cx1 = rand2(-10, 10)cy1 = rand2(-10, 10)cz1 = rand2(-10, 10)dx1 = rand2(-10, 10)dy1 = rand2(-10, 10)dz1 = rand2(-10, 10)ax2 = rand2(-10, 10)ay2 = rand2(-10, 10)az2 = rand2(-10, 10)bx2 = rand2(-10, 10)by2 = rand2(-10, 10)bz2 = rand2(-10, 10)cx2 = rand2(-10, 10)cy2 = rand2(-10, 10)cz2 = rand2(-10, 10)dx2 = rand2(-10, 10)dy2 = rand2(-10, 10)dz2 = rand2(-10, 10)ax3 = rand2(-10, 10)ay3 = rand2(-10, 10)az3 = rand2(-10, 10)bx3 = rand2(-10, 10)by3 = rand2(-10, 10)bz3 = rand2(-10, 10)cx3 = rand2(-10, 10)cy3 = rand2(-10, 10)cz3 = rand2(-10, 10)dx3 = rand2(-10, 10)dy3 = rand2(-10, 10)dz3 = rand2(-10, 10)u1 = pow((1-u),3) u2 = 3*pow((1-u),2)*u  u3 = 3*u*u*(1-u)u4 = u*u*uax = u1*ax0+u2*ax1+u3*ax2+u4*ax3ay = u1*ay0+u2*ay1+u3*ay2+u4*ay3az = u1*az0+u2*az1+u3*az2+u4*az3bx = u1*bx0+u2*bx1+u3*bx2+u4*bx3by = u1*by0+u2*by1+u3*by2+u4*by3bz = u1*bz0+u2*bz1+u3*bz2+u4*bz3cx = u1*cx0+u2*cx1+u3*cx2+u4*cx3cy = u1*cy0+u2*cy1+u3*cy2+u4*cy3cz = u1*cz0+u2*cz1+u3*cz2+u4*cz3dx = u1*dx0+u2*dx1+u3*dx2+u4*dx3dy = u1*dy0+u2*dy1+u3*dy2+u4*dy3dz = u1*dz0+u2*dz1+u3*dz2+u4*dz3v1 = pow((1-v),3) v2 = 3*pow((1-v),2)*v  v3 = 3*v*v*(1-v)v4 = v*v*vx = v1*ax+v2*bx+v3*cx+v4*dxy = v1*ay+v2*by+v3*cy+v4*dyz = v1*az+v2*bz+v3*cz+v4*dzu = u*10v = v*10

转载于:https://www.cnblogs.com/WhyEngine/p/3994158.html

你可能感兴趣的文章
Android打包key密码丢失找回
查看>>
VC6.0调试技巧(一)(转)
查看>>
类库与框架,强类型与弱类型的闲聊
查看>>
webView添加头视图
查看>>
php match_model的简单使用
查看>>
在NT中直接访问物理内存
查看>>
Intel HEX 文件格式
查看>>
SIP服务器性能测试工具SIPp使用指导(转)
查看>>
php_扑克类
查看>>
回调没用,加上iframe提交表单
查看>>
(安卓)一般安卓开始界面 Loding 跳转 实例 ---亲测!
查看>>
Mysql 索引优化 - 1
查看>>
LeetCode(3) || Median of Two Sorted Arrays
查看>>
大话文本检测经典模型:EAST
查看>>
待整理
查看>>
一次动态sql查询订单数据的设计
查看>>
C# 类(10) 抽象类.
查看>>
Vue_(组件通讯)子组件向父组件传值
查看>>
jvm参数
查看>>
我对前端MVC的理解
查看>>