找回密码
 注册
搜索
查看: 20701|回复: 2

[在线求助] 渐变倒角三角形表面代码求教

[复制链接]
发表于 2013-2-18 22:46:05 | 显示全部楼层 |阅读模式
本帖最后由 夜第七章 于 2013-2-18 22:49 编辑

这是在f8的那本《rhinoscript参数建模》上的渐变倒角三角形表面代码,我不知道在Function recursivetriangle(ByVal idsrf, ByVal A, ByVal B, ByVal D)这一段中红色这一段到底是怎么回事?arrdist(2) 不就是array(distAB, distBD, distAD)中的第三天AD吗?那么执行的不就一直是“If distAD = arrdist(2) Then”这段了么?
另外,我总觉得红色部分的byval按值传递在这里有些影响,但却一直理解不了~


我初学rs,对这代码里面的递归方法还是不太理解。看了很久,画了无数图了,还是不对劲,自己理解的过程和运行的过程不一致~
希望各位能帮我解决一下,感激不尽!


Sub Main()
Dim idsrf: idsrf = rhino.getobject ("select surface", 8, True, True)
Dim udomain: udomain = rhino.surfacedomain(idsrf, 0)
Dim vdomain: vdomain = rhino.SurfaceDomain(idsrf, 1)
Dim u0: u0 = udomain(0)
Dim u1: u1 = udomain(1)
Dim v0: v0 = vdomain(0)
Dim v1: v1 = vdomain(1)
Dim A: A = rhino.EvaluateSurface(idsrf, array(u0,v0))
Dim B: B = rhino.evaluatesurface(idsrf, array(u1,v0))
Dim C: C = rhino.evaluatesurface(idsrf, array(u1,v1))
Dim D: D = rhino.EvaluateSurface(idsrf, array(u0,v1))
Call recursivetriangle(idsrf, A, B, D)
Call recursivetriangle(idsrf, B, C, D)
End Sub
Function recursivetriangle(ByVal idsrf, ByVal A, ByVal B, ByVal D)
Dim distAB: distAB = rhino.distance(A, B)
Dim distBD: distBD = rhino.Distance(B, D)
Dim distAD: distAD = rhino.Distance(A, D)
Dim arrdist: arrdist = array(distAB, distBD, distAD)
arrdist = rhino.sortnumbers(arrdist,True)
Dim H,K,J
If distAB = arrdist(2) Then
  H = A
  K = B
  J = D
End If
If distBD = arrdist(2) Then
  H = B
  K = D
  J = A
End If
If distAD = arrdist(2) Then
  H = A
  K = D
  J = B
End If
Dim Z(2)
Z(0) = (H(0)+K(0))/2
Z(1) = (H(1)+K(1))/2
Z(2) = (H(2)+K(2))/2
Dim Zuv: Zuv = rhino.surfaceclosestpoint(idsrf, Z)
Dim Zp: Zp = rhino.evaluatesurface (idsrf, Zuv)
Dim distcurv: distcurv = rhino.distance (Zp, Z)
Dim distang: distang = rhino.Distance (H, K)
If (distcurv < 0.9) And (distang< 30) Then
  Dim crv0 : crv0 = rhino.addcurve(array(A,B,D,A), 2)
  Call rhino.SelectObject(crv0)
  Dim pipeRadius1
  pipeRadius1=0.9
  rhino.Command("_Pipe" & " " & pipeRadius1 & " _Enter _Enter")
  Rhino.UnselectAllObjects()
Else
  Call recursivetriangle (idsrf, H, J, Zp)
  Call recursivetriangle (idsrf, K, J, Zp)
End If
End Function
发表于 2013-2-22 23:41:02 | 显示全部楼层
顶楼主一个~~~~~~~~~~~~~
回复

使用道具 举报

 楼主| 发表于 2013-2-23 10:40:17 | 显示全部楼层
回复

使用道具 举报

NCFZ微信公众号

手机版|小黑屋|NCF参数化建筑论坛 ( 浙ICP备2020044100号-2 ) 辽公网安备21021102000973号

GMT+8, 2026-11-23 22:03 , Processed in 0.038243 second(s), 19 queries , Gzip On.

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表