August 27, 2010

Rhinoscript | Boy surface



http://mathworld.wolfram.com/BoySurface.html

Option Explicit
'2010년 8월 27일 금요일
'Script written by Sanghoon Yoon @ +plastic
'Script copyrighted by +plastic

main
Sub main()
 
  Dim PP, N, ST, i, u,v, X,Y,Z, A,B,C, arrPoints 
    PP=Rhino.Pi
    N=50
    ST=PP/(N-1)
 
  ReDim arrPoints(N*N-1)

    i=0
  For u=0 To PP Step ST
    For v=0 To PP Step ST
   
      A= Cos(u)*Sin(v) : B=Sin(u)*Sin(v) : C=Cos(v)

      X=0.5*(2*A^2-B^2-C^2+2*B*C*(B^2-c^2)+C*A*(A^2-C^2)+A*B*(B^2-A^2))
      Y=Sqr(3)/2*(B^2-C^2+(C*A*(C^2-A^2)+A*B*(B^2-A^2)))
      Z=(A+B+C)*((A+B+C)^3+4*(B-A)*(C-B)*(A-C))/5

      arrPoints(i) =Array(X,Y,Z)
      i=i+1
    Next
  Next

  Rhino.AddSrfPtGrid Array(N,N), arrPoints

End Sub




3 comments:

Anonymous said...

Script gives error

Type Mismatch in parameter array required

Line 31
Char 2

SPD3159 Theme Park (Hong Kong Disneyland) said...

oh... it seems so complicated!! flighting!!

yoon said...

Anonymous, I don't know why, it works fine for me. If you are using Rhino V4 SR5 or older version, try to update your Rhino to recent one(SR8).