def __init__(this, *args, **kwargs): t1 = Rot(axis=vec(0, 0, 1), angle=GeomTypes.turn(0.2)) t2 = Rot(axis=vec(0, 0, 1), angle=GeomTypes.turn(0.4)) t3 = Rot(axis=vec(0, 0, 1), angle=GeomTypes.turn(0.6)) t4 = Rot(axis=vec(0, 0, 1), angle=GeomTypes.turn(0.8)) h0 = HalfTurn(vec(0, 1, tau)) Heptagons.EqlHeptagonShape.__init__( this, directIsometries=[ GeomTypes.E, t1, t2, t3, t4, h0, h0 * t1, h0 * t2, h0 * t3, h0 * t4, t1 * h0, t1 * h0 * t1, t1 * h0 * t2, t1 * h0 * t3, t1 * h0 * t4, t2 * h0, t2 * h0 * t1, t2 * h0 * t2, t2 * h0 * t3, t2 * h0 * t4, t3 * h0, t3 * h0 * t1, t3 * h0 * t2, t3 * h0 * t3, t3 * h0 * t4, t4 * h0, t4 * h0 * t1, t4 * h0 * t2, t4 * h0 * t3, t4 * h0 * t4 ], # abuse the opposite isometry (even though this is not an opposite # isometry really) But for historical reasons I used a half turn # here to prevent edges to be drawn twice. #oppositeIsometry = GeomTypes.I, oppositeIsometry=GeomTypes.Hx, name='EglHeptA5xI_GD') this.initArrs() this.setH(H0) this.setViewSettings(edgeR=0.01, vertexR=0.02)
def __init__(this, *args, **kwargs): this.atanHV2 = Geom3D.Rad2Deg * math.atan(1/V2) Heptagons.EqlHeptagonShape.__init__(this, directIsometries = [ GeomTypes.E, Rot(angle = GeomTypes.turn(0.25), axis = GeomTypes.uz), Rot(angle = GeomTypes.turn(0.50), axis = GeomTypes.uz), Rot(angle = GeomTypes.turn(0.75), axis = GeomTypes.uz) ], # abuse the opposite isometry (even though this is not an opposite # isometry really) But for historical reasons I used a half turn # here to prevent edges to be drawn twice. #oppositeIsometry = GeomTypes.I, oppositeIsometry = halfTurn, name = 'EglHeptS4xI' ) this.initArrs() this.setH(1.0) this.setViewSettings(edgeR = 0.02, vertexR = 0.04)
def setV(this): this.posHeptagon() Vs = this.heptagon.Vs[:] # 5" = 18 12 = 2" # 6" = 16 10 = 1" # 0 # 5' = 17 o3 o3 11 = 2' # 6 1 # # 6' = 15 9 = 1' # # 5 2 # # # 14 4 3 8 = 0' # # # 2' = 13 7 = 5' Rr = Rot(axis=Vec([1, 1, 1]), angle=GeomTypes.tTurn) Rl = Rot(axis=Vec([-1, 1, 1]), angle=-GeomTypes.tTurn) Vs.append(Vec([-Vs[5][0], -Vs[5][1], Vs[5][2]])) # Vs[7] Vs.append(Rr * Vs[0]) # Vs[8] Vs.append(Rr * Vs[1]) # Vs[9] Vs.append(Rr * Vs[9]) # Vs[10] Vs.append(Rr * Vs[2]) # Vs[11] Vs.append(Rr * Vs[11]) # Vs[12] Vs.append(Vec([-Vs[2][0], -Vs[2][1], Vs[2][2]])) # Vs[13] Vs.append(Rl * Vs[0]) # Vs[14] Vs.append(Rl * Vs[6]) # Vs[15] Vs.append(Rl * Vs[-1]) # Vs[16] Vs.append(Rl * Vs[5]) # Vs[17] Vs.append(Rl * Vs[-1]) # Vs[18] Vs.append(Rr * Vs[8]) # Vs[19] = V0" Vs.append(Rr * Vs[6]) # Vs[20] = V6'" Vs.append(Rr * Vs[5]) # Vs[21] = V5'" Vs.append(Rl * Vs[13]) # Vs[22] = V13' Vs.append(Rl * Vs[-1]) # Vs[23] = V13" this.baseVs = Vs #for i in range(len(Vs)): # print 'Vs[%d]:' % i, Vs[i] Es = [] Fs = [] Fs.extend(this.heptagon.Fs) # use extend to copy the list to Fs Es.extend(this.heptagon.Es) # use extend to copy the list to Fs this.heptagonsShape.setBaseVertexProperties(Vs=Vs) this.heptagonsShape.setBaseEdgeProperties(Es=Es) # comment out this and nvidia driver crashes:... this.heptagonsShape.setBaseFaceProperties(Fs=Fs) this.heptagonsShape.setFaceColors(heptColPerIsom) theShapes = [this.heptagonsShape] if this.addXtraFs: Es = this.o3triEs[this.edgeAlternative][:] Fs = this.o3triFs[this.edgeAlternative][:] Es.extend(this.oppO3triEs[this.oppEdgeAlternative]) Fs.extend(this.oppO3triFs[this.oppEdgeAlternative]) this.trisO3Shape.setBaseVertexProperties(Vs=Vs) this.trisO3Shape.setBaseEdgeProperties(Es=Es) this.trisO3Shape.setBaseFaceProperties(Fs=Fs) theShapes.append(this.trisO3Shape) if (not this.onlyRegFs): # when you use the rot alternative the rot is leading for # choosing the colours. if this.oppEdgeAlternative & Heptagons.rot_bit: eAlt = this.oppEdgeAlternative else: eAlt = this.edgeAlternative Es = this.triEs[this.edgeAlternative][:] if this.edgeAlternative == trisAlt.twist_strip_I: Fs = this.triFs[this.edgeAlternative][ this.inclReflections][:] Fs.extend(this.oppTriFs[this.oppEdgeAlternative][ this.inclReflections]) Es.extend(this.oppTriEs[this.oppEdgeAlternative][ this.inclReflections]) # only draw the folds of the hexagon for the twisted variant # if the hexagon isn't flat. if (not Geom3D.eq( abs(this.posAngle) % (math.pi / 2), math.pi / 4)): Es.extend(this.twistedEs_A4) colIds = this.triColIds[eAlt][this.inclReflections] else: Fs = this.triFs[this.edgeAlternative][:] Fs.extend(this.oppTriFs[this.oppEdgeAlternative]) Es.extend(this.oppTriEs[this.oppEdgeAlternative]) colIds = this.triColIds[eAlt] this.xtraTrisShape.setBaseVertexProperties(Vs=Vs) this.xtraTrisShape.setBaseEdgeProperties(Es=Es) this.xtraTrisShape.setBaseFaceProperties( Fs=Fs, colors=([rgb.darkRed[:], rgb.yellow[:], rgb.magenta[:]], colIds)) theShapes.append(this.xtraTrisShape) for shape in theShapes: shape.showBaseOnly = not this.applySymmetry this.setShapes(theShapes) this.updateShape = False
x = v1[0] - v0[0] y = v1[1] - v0[1] z = v1[2] - v0[2] return (math.sqrt(x * x + y * y + z * z)) V2 = math.sqrt(2) V3 = math.sqrt(3) V5 = math.sqrt(5) tau = (1.0 + V5) / 2 tau2 = tau + 1 dtau = 1.0 / tau isomA5 = isometry.A5() o5axis = GeomTypes.Vec([1, 0, tau]) o5fld = Rot(axis=o5axis, angle=GeomTypes.turn(1.0 / 5)) _o5fld = Rot(axis=o5axis, angle=GeomTypes.turn(-1.0 / 5)) isomO5 = isometry.C5(setup={'axis': o5axis}) o3axis = GeomTypes.Vec([0, dtau, tau]) o3fld = Rot(axis=o3axis, angle=GeomTypes.tTurn) isomO3 = isometry.C3(setup={'axis': o3axis}) # get the col faces array by using a similar shape here, so it is calculated # only once colStabilisers = [ isometry.A4(setup={ 'o2axis0': [1.0, 0.0, 0.0], 'o2axis1': [0.0, 0.0, 1.0], }), isometry.A4(setup={
pos_angle_refl_2 = math.pi/2 def Vlen(v0, v1): x = v1[0] - v0[0] y = v1[1] - v0[1] z = v1[2] - v0[2] return (math.sqrt(x*x + y*y + z*z)) V2 = math.sqrt(2) V3 = math.sqrt(3) hV2 = V2/2 o4_fld_0 = GeomTypes.Vec3([1, 0, 0]) o4_fld_1 = GeomTypes.Vec3([0, 1, 1]) isomS4 = isometry.S4(setup = {'o4axis0': o4_fld_0, 'o4axis1': o4_fld_1}) o4fld = Rot(axis = o4_fld_1, angle = GeomTypes.qTurn) isomO4 = isometry.C4(setup = {'axis': o4_fld_1}) o3axis = GeomTypes.Vec3([1/V3, 0, V2/V3]) o3fld = Rot(axis = o3axis, angle = GeomTypes.tTurn) isomO3 = isometry.C3(setup = {'axis': o3axis}) # get the col faces array by using a similar shape here, so it is calculated # only once colStabilisers = [ isometry.D2(setup = { 'axis_n': [0.0, 0.0, 1.0], 'axis_2': [1.0, 0.0, 0.0], }), isometry.D2(setup = { 'axis_n': [1.0, 0.0, 0.0],
def setV(this): # input this.h St = this.h / (Dtau2 * V3 * this.h - 3) #print 's', St # # 0 # __..--'-_ # 3 -'' . _"- 1 # \ _-' # \ _-' # \-' # 2 # # z y # ^ 7\ # |/ # ---> x # # # The kite above is a 5th of the top face of dodecahedron # standing on 1 face, 2 is a vertex, 1 and 3, centres of two edges # and 0 a face centre. # Vs = [ vec(0.0, 0.0, this.h), # 0 Rl, vec(0.0, -Dtau2 * St, St), vec(-Rl[0], Rl[1], Rl[2]) # 3 ] # add heptagons H = HalfTurn(Vs[3]) this.errorStr = '' if not this.heptPosAlt: Ns = Vs heptN = Heptagons.Kite2Hept(Vs[3], Vs[0], Vs[1], Vs[2]) if heptN == None: this.errorStr = 'No valid equilateral heptagon for this position' return Mr = Rot(axis=GeomTypes.Vec3(Vs[2]), angle=GeomTypes.turn(0.2)) # p is a corner of the pentagon inside the pentagram # p is rotated 1/5th turn to form a triangle # together with 2 corners of the pentagram: # 5 of these triangles will cover the pentagram. # this is easier than finding the centre of the pentagram. v3 = heptN[0][3] v4 = heptN[0][4] p = v3 + (v4 - v3) / tau v = Mr * p if this.triangleAlt: vt = heptN[0][6] xtraEdgeIndex = 15 else: vt = heptN[0][5] xtraEdgeIndex = 14 # A part that will form the regular pentagrams (with overlaps). RegularTrianglePartV = [ heptN[0][3], heptN[0][4], vec(v[0], v[1], v[2]), ] RegularTrianglePartN = Vs[2] # vt is the vertex that will be projected by a half turn on the # third vertex of the isosceles triangle. IsoscelesTriangleV = [heptN[0][5], heptN[0][6], vt] else: heptN = Heptagons.Kite2Hept(Vs[1], Vs[2], Vs[3], Vs[0]) if heptN == None: this.errorStr = 'No valid equilateral heptagon for this position' return if this.triangleAlt: vt = heptN[0][1] xtraEdgeIndex = 14 else: vt = heptN[0][2] xtraEdgeIndex = 15 # One third of regular triangle. RegularTrianglePartV = [ heptN[0][3], heptN[0][4], vec(0, 0, heptN[0][3][2]), ] RegularTrianglePartN = RegularTrianglePartV[2] # vt is the vertex that will be projected by a half turn on the # third vertex of the isosceles triangle. IsoscelesTriangleV = [heptN[0][1], heptN[0][2], vt] if heptN == None: this.errorStr = 'No valid equilateral heptagon for this position' return else: this.errorStr = '' vt = H * vt # rotate vt by a half turn, IsoscelesTriangleV NOT auto updated. IsoscelesTriangleV[2] = vt Vs.extend(heptN[0]) # V4 - V10, the heptagon Vs.extend(RegularTrianglePartV) # V11 - V13 Vs.extend(IsoscelesTriangleV) # V14 - V16 #for V in Vs: print V #h = heptN[1] #Ns = [[-h[0], -h[1], -h[2]] for i in range(11)] Ns = [heptN[1] for i in range(11)] Ns.extend([RegularTrianglePartN for i in range(3)]) IsoscelesTriangleN = Geom3D.Triangle(IsoscelesTriangleV[0], IsoscelesTriangleV[1], IsoscelesTriangleV[2]).normal() Ns.extend([IsoscelesTriangleN for i in range(3)]) this.xtraEs = [] if this.addXtraEdge: this.xtraEs = [xtraEdgeIndex, 16] #this.showBaseOnly = True this.setBaseVertexProperties(Vs=Vs, Ns=Ns) Fs = [] Es = [] colIds = [] if this.showKite: Fs.extend(this.kiteFs) Es.extend(this.kiteEs) colIds.extend(this.kiteColIds) if this.showHepta: Fs.extend(this.heptFs) Es.extend(this.heptEs) colIds.extend(this.heptColIds) if this.showXtra: Fs.extend(this.xtraFs) Es.extend(this.xtraEs) colIds.extend(this.xtraColIds) this.setBaseEdgeProperties(Es=Es) this.setBaseFaceProperties(Fs=Fs, colors=(this.theColors, colIds)) this.Vs = Vs
def setV(this): # input this.h St = this.h / (4 - tau2 - (4 * this.h / tau2)) # z # ^ # | # ---> y # / # V_ # x # 2 # __..--'-_ # 1 -'' . _"- 3 # \ _-' # \ _-' # \-' # 0 # # The kite above is a 5th of the top face of dodecahedron # standing on 1 face, 2 is a vertex, 1 and 3, centres of two edges # and 0 a face centre. # Vs = [ vec(0.0, 0.0, this.h), # 0 vec(-tau2/2, -w, tau2), vec(2.0*St, 0.0, -tau2*St), vec(-tau2/2, w, tau2) # 3 ] # add heptagons Ns = Vs if this.heptPosAlt: heptN = Heptagons.Kite2Hept(Vs[3], Vs[0], Vs[1], Vs[2]) if heptN == None: return Mr = Rot(angle = GeomTypes.tTurn, axis = Vs[2]) v = Mr*heptN[0][4] if this.triangleAlt: vt = heptN[0][6] xtraEdgeIndex = 15 else: vt = heptN[0][5] xtraEdgeIndex = 14 #print v # One third of regular triangle. RegularTrianglePartV = [ heptN[0][3], heptN[0][4], vec(v[0], v[1], v[2]), ] # vt is the vertex that will be projected by a half turn on the # third vertex of the isosceles triangle. IsoscelesTriangleV = [ heptN[0][5], heptN[0][6], vt ] else: heptN = Heptagons.Kite2Hept(Vs[1], Vs[2], Vs[3], Vs[0]) if heptN == None: return if this.triangleAlt: vt = heptN[0][1] xtraEdgeIndex = 14 else: vt = heptN[0][2] xtraEdgeIndex = 15 # One third of regular pentagon. RegularTrianglePartV = [ heptN[0][3], heptN[0][4], vec(0, 0, heptN[0][3][2]), ] # vt is the vertex that will be projected by a half turn on the # third vertex of the isosceles triangle. IsoscelesTriangleV = [ heptN[0][1], heptN[0][2], vt ] if heptN == None: this.errorStr = 'No valid equilateral heptagon for this position' return else: this.errorStr = '' H = HalfTurn(Vs[3]) vt = H * vt IsoscelesTriangleV[2] = vt Vs.extend(heptN[0]) # V4 - V10 Vs.extend(RegularTrianglePartV) # V11 - V13 Vs.extend(IsoscelesTriangleV) # V14 - V16 #for V in Vs: print V Ns = [heptN[1] for i in range(11)] RegularTrianglePartN = RegularTrianglePartV[2] Ns.extend([RegularTrianglePartN for i in range(3)]) IsoscelesTriangleN = Geom3D.Triangle( IsoscelesTriangleV[0], IsoscelesTriangleV[1], IsoscelesTriangleV[2] ).normal() Ns.extend([IsoscelesTriangleN for i in range(3)]) this.xtraEs = [] if this.addXtraEdge: this.xtraEs = [xtraEdgeIndex, 16] #this.showBaseOnly = True this.setBaseVertexProperties(Vs = Vs, Ns = Ns) Fs = [] Es = [] colIds = [] if this.showKite: Fs.extend(this.kiteFs) Es.extend(this.kiteEs) colIds.extend(this.kiteColIds) if this.showHepta: Fs.extend(this.heptFs) Es.extend(this.heptEs) colIds.extend(this.heptColIds) if this.showXtra: Fs.extend(this.xtraFs) Es.extend(this.xtraEs) colIds.extend(this.xtraColIds) this.setBaseEdgeProperties(Es = Es) this.setBaseFaceProperties(Fs = Fs, colors = (this.theColors, colIds)) this.Vs = Vs