""" Scherk Surface 11.05.2020 """ import c4d import math import cmath # Variablen und Konstanten dialog_title = 'Scherk Surface' uMin = -2*math.pi # Bereich u uMax = 2*math.pi # Bereich u vMin = -math.pi/2 # Bereich v vMax = math.pi/2 # Bereich v Nu = 750 # Anzahl Punkte u Nv = 250 # Anzahl Punkte v Faktor = 100 # Skalierungsfaktor def CreatePolygonObject(): # Polygonobjekt erzeugen obj = c4d.BaseObject(c4d.Opolygon) obj.ResizeObject((Nu+1)*(Nv+1), Nu*Nv) obj.SetName(dialog_title) # Variablen zz=0 # Zaehler # Segmentbreiten berechnen du=(uMax-uMin)/Nu dv=(vMax-vMin)/Nv # Punkte erzeugen for i in xrange(0,Nu+1): for j in xrange(0,Nv+1): # Berechnung der Parameter u=uMin+i*du v=vMin+j*dv # Kompklexe Zahl definieren w=complex(u, v) # print(cmath.log(w)) #print(cmath.atan(w)) # Berechnung der Koordinaten wx=cmath.log(1+u*cmath.exp(complex(0, 1)*v))-cmath.log(1-u*cmath.exp(complex(0, 1)*v)) wy=4*complex(0, 1)*cmath.atan(u*cmath.exp(complex(0, 1)*v)) wz=2*complex(0, 1)*(-cmath.log(1-u*u*cmath.exp(2*complex(0, 1)*v))+cmath.log(1+u*u*cmath.exp(2*complex(0, 1)*v))) x = 2*wx.real y = wy.real z = wz.real # Punkt speichern obj.SetPoint(zz, c4d.Vector(x*Faktor,z*Faktor,y*Faktor)) # Zähler erhöhen zz=zz+1 # Polygone erzeugen zz=0 # Zähler zurücksetzen for j in xrange(0,Nv): for i in xrange(0,Nu): # Punkte für ein Quadrat definieren P1=i*(Nv+1)+j P2=i*(Nv+1)+j+1 P3=(i+1)*(Nv+1)+j+1 P4=(i+1)*(Nv+1)+j # Quadrat speichern obj.SetPolygon(zz, c4d.CPolygon(P1,P2,P3,P4)) # Zähler erhöhen zz=zz+1 # obj.Message(c4d.MSG_UPDATE) return obj def main(): plyobj = CreatePolygonObject() doc.InsertObject(plyobj, None, None, True) c4d.EventAdd() if __name__=='__main__': main()