""" Scherk Surface 11.05.2020 """ import c4d import math import cmath # Variablen und Konstanten dialog_title = 'Scherk Surface' # m = 4 # Konstante uMin = -2*math.pi # Bereich u uMax = 2*math.pi # Bereich u vMin = -2*math.pi # Bereich v vMax = 2*math.pi # Bereich v Nu = 500 # 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) # Berechnung der Koordinaten wx=0.5*cmath.log((w+complex(0, 1))/(w-complex(0, 1))) wy=-0.5*cmath.log((1+w)/(1-w)) wz=-0.5*complex(0, 1)*cmath.log((1+w*w)/(1-w*w)) x = 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()