lebron 发表于 2010-4-5 11:09:36

help里的建模例子,怎么实现的呢,给解释一下,谢谢。

这个程序是怎么实现的呢?
new
def parm
rad=10.0   ; radius of spherical cavity
len=20.0    ; length of outer box edge
in_size=6   ; number of zones along outer cube edge
rad_size=10 ; number of zones in radial direction
end
parm
gen zone radbrick edge len size in_size in_size in_size rad_size &
rat 1.0 1.0 1.0 1.2 dim rad rad rad
pl set rot 340 0 30
pl surf wh
def make_sphere
; Loop over all GPs and remap their coordinates:
;assume len>rad
p_gp=gp_head
i = 0
loop while p_gp#null
; Get gp coordinate: P=(px,py,pz)
    px=gp_xpos(p_gp)
    py=gp_ypos(p_gp)
    pz=gp_zpos(p_gp)
; Compute A=(ax,ay,az)=point on sphere radially "below" P.
    dist=sqrt(px*px+py*py+pz*pz)
    if dist>0 then         ;为什么要dist>0呢?
      k=rad/dist
      ax=px*k
      ay=py*k
      az=pz*k
; Compute B=(bx,by,bz)=point on outer box boundary radially "above" P.
      maxp=max(px,max(py,pz))
      k=len/maxp
      bx=px*k
      by=py*k
      bz=pz*k
; Linear interpolation: P=A+u*(B-A)
      u=(maxp-rad)/(len-rad)
      gp_xpos(p_gp)=ax+u*(bx-ax)
      gp_ypos(p_gp)=ay+u*(by-ay)
      gp_zpos(p_gp)=az+u*(bz-az)
      i = i + 1
    end_if
    p_gp=gp_next(p_gp)
end_loop
end
make_sphere
pl surf yel

lebron 发表于 2010-4-5 11:10:22

自己先顶一个,希望高手帮忙,谢谢@!

lebron 发表于 2010-4-5 15:31:47

版主在不》?给解释一下?
页: [1]
查看完整版本: help里的建模例子,怎么实现的呢,给解释一下,谢谢。