def printTrisAngles(this): # TODO: fix this function. Which angles to take (ie which faces) depends # on the triangle alternative. tris = this.triFs[this.edgeAlternative] # for non 1 loose # for i in range(0, len(tris) - 2, 2): d = 2 # for 1 loose: d = 1 for i in range(2): norm0 = Geom3D.Triangle( this.baseShape.Vs[tris[i][0]], this.baseShape.Vs[tris[i][1]], this.baseShape.Vs[tris[i][2]], ).normal(True) print 'norm0 %d: ', norm0 norm1 = Geom3D.Triangle( this.baseShape.Vs[tris[i + d][0]], this.baseShape.Vs[tris[i + d][1]], this.baseShape.Vs[tris[i + d][2]], ).normal(True) print 'norm1 %d: ', norm1 inprod = norm0 * norm1 print 'Tris angle %d: %.6f degrees' % (i, math.acos(inprod) * Geom3D.Rad2Deg) print '------------' # TODO move out
def setV(this): # input this.h St = this.h / (4*this.h - 1) if this.heptPosAlt: # # z # ^ # | # ---> y # / # V_ # x # # There are vertices with more than one index, because the normals # will differ. # # '-, # / '-, # / -.2 # | 5 -' \ 1, 11 # / 3.-' 0 '- # | / 4 8 __'-10 # / ,-' __--"" # /,=---"" 7 # 6 9 # # For tetrahedral position: 1, 3, and 5 are on the vertices of a # cube and 2, 4, 6, are on the face centres of that cube # Vs = [ vec( St, St, -St), # 0 vec( 0.0, 1.0, 0.0), vec( this.h, this.h, this.h), vec( 1.0, 0.0, 0.0), # 3 vec( St, St, -St), # 4 vec( 1.0, 0.0, 0.0), vec( this.h, -this.h, -this.h), vec( 0.0, 0.0, -1.0), # 7 vec( St, St, -St), # 8 vec( 0.0, 0.0, -1.0), vec(-this.h, this.h, -this.h), vec( 0.0, 1.0, 0.0) # 11 ] # Normals are set below, after calculating the heptagons #this.Ns = this.NsAlt else: # # z # ^ # | # ---> y # / # V_ # x # # There are vertices with more than one index, because the normals # will differ. # # 6 # 9 / # '-, 7 V_ # / '-, # / -.0, 4, 8 # | 10 -' \ 3, 5 # /11,1.-' '- # | / 2 __'- # / ,-' __--"" # /,=---"" # # # For tetrahedral position: 1, 3, and 5 are on the vertices of a # cube and 2, 4, 6, are on the face centres of that cube # Vs = [ vec( this.h, this.h, this.h), # 0 vec( 1.0, 0.0, 0.0), vec( St, St, -St), vec( 0.0, 1.0, 0.0), # 3 vec( this.h, this.h, this.h), # 4 vec( 0.0, 1.0, 0.0), vec(-St, St, St), vec( 0.0, 0.0, 1.0), # 7 vec( this.h, this.h, this.h), # 8 vec( 0.0, 0.0, 1.0), vec( St, -St, St), vec( 1.0, 0.0, 0.0) # 11 ] # Normals are set below, after calculating the heptagons #this.Ns = this.NsPref # add heptagons heptN = Heptagons.Kite2Hept(Vs[3], Vs[2], Vs[1], Vs[0]) if heptN == None: this.errorStr = 'No valid equilateral heptagon for this position' return else: this.errorStr = '' Vs.extend(heptN[0]) # V12 - V18 Ns = range(33) for i in range(4): Ns[i] = heptN[1] for i in range(12, 19): Ns[i] = heptN[1] heptN = Heptagons.Kite2Hept(Vs[7], Vs[6], Vs[5], Vs[4]) Vs.extend(heptN[0]) # V19 - V25 for i in range(4, 8): Ns[i] = heptN[1] for i in range(19, 26): Ns[i] = heptN[1] heptN = Heptagons.Kite2Hept(Vs[11], Vs[10], Vs[9], Vs[8]) Vs.extend(heptN[0]) # V26 - V32 for i in range(8, 12): Ns[i] = heptN[1] for i in range(26, 33): Ns[i] = heptN[1] # add equilateral triangles: Vs.extend([Vs[15], Vs[22], Vs[29]]) # V33 - V35 # add isosceles triangles: this.xtraEs = [] if this.triangleAlt: Vs.extend([Vs[13], Vs[14], Vs[32]]) # V36 - V38 Vs.extend([Vs[20], Vs[21], Vs[18]]) # V39 - V41 Vs.extend([Vs[27], Vs[28], Vs[25]]) # V42 - V44 if this.addXtraEdge: this.xtraEs = [36, 38, 39, 41, 42, 44] else: Vs.extend([Vs[13], Vs[14], Vs[14]]) # V36 - V38 Vs.extend([Vs[20], Vs[21], Vs[21]]) # V39 - V41 Vs.extend([Vs[27], Vs[28], Vs[28]]) # V42 - V44 if this.heptPosAlt: v = Vs[38] Vs[38] = vec(-v[0], v[1], -v[2]) # Hy * V9 v = Vs[41] Vs[41] = vec( v[0], -v[1], -v[2]) # Hx * V23 else: v = Vs[38] Vs[38] = vec( v[0], -v[1], -v[2]) # Hx * V9 v = Vs[41] Vs[41] = vec(-v[0], v[1], -v[2]) # Hy * V23 v = Vs[44] Vs[44] = vec(-v[0], -v[1], v[2]) # Hz * V16 if this.addXtraEdge: this.xtraEs = [37, 38, 40, 41, 43, 44] # normal of equilateral triangle for i in range(3): Ns.append(Vs[0]) # normal of isosceles triangles for i in range(3): o = 36 + 3*i IsoscelesTriangleN = Geom3D.Triangle( Vs[o], Vs[o+1], Vs[o+2] ).normal() Ns.extend([IsoscelesTriangleN, IsoscelesTriangleN, IsoscelesTriangleN]) this.xtraFs = [ [33, 34, 35], [36, 37, 38], [39, 40, 41], [42, 43, 44] ] 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))
def setV(this): # input this.h St = this.h / (2*this.h - 1) if this.heptPosAlt: # # z # ^ # | # ---> y # / # V_ # x # # .------------. # ,' 2 _____1,'| # ,' ,' ,'11| # .-----3.----0' | | # | 5| 4|8 | | # | | | ,' | # | +-----+' 10- # | 6 7|9 ,' # | |,' # '------------' # Vs = [ vec(St, St, St), # 0 vec(0.0, 1.0, 1.0), vec(0.0, 0.0, this.h), vec(1.0, 0.0, 1.0), # 3 vec(St, St, St), # 4 vec(1.0, 0.0, 1.0), vec(this.h, 0.0, 0.0), vec(1.0, 1.0, 0.0), # 7 vec(St, St, St), # 8 vec(1.0, 1.0, 0.0), vec(0.0, this.h, 0.0), vec(0.0, 1.0, 1.0) # 11 ] else: # # z # ^ # | # ---> y # / # V_ # x # # .------------. # ,' 0 _____3,'| # ,' ,' ,'|9| # .-----1.----2' | | # | 7| 6|10| | # | | | ,' | # | +-----+' 8 - # | 4 5|11,' # | |,' # '------------' # Vs = [ vec(0.0, 0.0, this.h), # 0 vec(1.0, 0.0, 1.0), vec(St, St, St), vec(0.0, 1.0, 1.0), # 3 vec(this.h, 0.0, 0.0), # 4 vec(1.0, 1.0, 0.0), vec(St, St, St), vec(1.0, 0.0, 1.0), # 7 vec(0.0, this.h, 0.0), # 8 vec(0.0, 1.0, 1.0), vec(St, St, St), vec(1.0, 1.0, 0.0), # 11 ] # add heptagons heptN = Heptagons.Kite2Hept(Vs[3], Vs[2], Vs[1], Vs[0]) if heptN == None: this.errorStr = 'No valid equilateral heptagon for this position' return else: this.errorStr = '' Vs.extend(heptN[0]) # V12 - V18 Ns = range(33) for i in range(4): Ns[i] = heptN[1] for i in range(12, 19): Ns[i] = heptN[1] heptN = Heptagons.Kite2Hept(Vs[7], Vs[6], Vs[5], Vs[4]) Vs.extend(heptN[0]) # V19 - V25 for i in range(4, 8): Ns[i] = heptN[1] for i in range(19, 26): Ns[i] = heptN[1] heptN = Heptagons.Kite2Hept(Vs[11], Vs[10], Vs[9], Vs[8]) Vs.extend(heptN[0]) # V26 - V32 for i in range(8, 12): Ns[i] = heptN[1] for i in range(26, 33): Ns[i] = heptN[1] xtraEs = [] # add extra faces: if this.heptPosAlt: # Eql triangle Vs.extend([Vs[15], Vs[22], Vs[29]]) # V33 - V35 # Isosceles triangles if this.triangleAlt: Vs.extend([Vs[13], Vs[14], Vs[32]]) # V36 - V38 Vs.extend([Vs[20], Vs[21], Vs[18]]) # V39 - V41 Vs.extend([Vs[27], Vs[28], Vs[25]]) # V42 - V44 else: v = Vs[14] Vs.extend([Vs[13], Vs[14], vec(-v[0], v[1], v[2])]) # V36 - V38 v = Vs[21] Vs.extend([Vs[20], Vs[21], vec( v[0], -v[1], v[2])]) # V39 - V41 v = Vs[28] Vs.extend([Vs[27], Vs[28], vec( v[0], v[1], -v[2])]) # V42 - V44 for i in range(3): Ns.append(Vs[0]) # N33 - N35 # normals for the isosceles triangles: # N36 - N38, N39 - N41 and N42 - N44 for i in range(3): o = 36 + 3*i IsoscelesTriangleN = Geom3D.Triangle( Vs[o], Vs[o+1], Vs[o+2] ).normal() Ns.extend([IsoscelesTriangleN, IsoscelesTriangleN, IsoscelesTriangleN]) xtraFs = [ # Eql triangle [33, 34, 35], # Isosceles triangles [36, 37, 38], [39, 40, 41], [42, 43, 44], ] this.xtraColIds = [2 for i in range(4)] if this.addXtraEdge: if this.triangleAlt: xtraEs = [36, 38, 39, 41, 42, 44] else: xtraEs = [37, 38, 40, 41, 43, 44] else: # The Squares, divided into rectangular isosceles triangles, # because of the sym-op Vs.extend([Vs[15], Vs[16], vec(0, 0, Vs[15][2])]) # V33 - V35 Vs.extend([Vs[22], Vs[23], vec(Vs[22][0], 0, 0)]) # V36 - V38 Vs.extend([Vs[29], Vs[30], vec(0, Vs[29][1], 0)]) # V39 - V41 # add isosceles triangles: if this.triangleAlt: v = Vs[13] Vs.extend([Vs[13], Vs[14], vec(v[0], -v[1], v[2])]) # V42 - V44 v = Vs[20] Vs.extend([Vs[20], Vs[21], vec(v[0], v[1], -v[2])]) # V45 - V47 v = Vs[27] Vs.extend([Vs[27], Vs[28], vec(-v[0], v[1], v[2])]) # V48 - V50 else: Vs.extend([Vs[13], Vs[14], Vs[24]]) # V42 - V44 Vs.extend([Vs[20], Vs[21], Vs[31]]) # V45 - V47 Vs.extend([Vs[27], Vs[28], Vs[17]]) # V48 - V50 # normals for the equilateral triangles: for i in range(3): Ns.append(Vs[0]) # N33 - N35 for i in range(3): Ns.append(Vs[4]) # N36 - N38 for i in range(3): Ns.append(Vs[8]) # N39 - N41 # normals for the isosceles triangles: # N42 - N44, N45 - N47 and N48 - N50 for i in range(3): o = 42 + 3*i IsoscelesTriangleN = Geom3D.Triangle( Vs[o], Vs[o+1], Vs[o+2] ).normal() Ns.extend([IsoscelesTriangleN, IsoscelesTriangleN, IsoscelesTriangleN]) xtraFs = [ # square parts: [33, 34, 35], [36, 37, 38], [39, 40, 41], # isosceles triangles: [42, 43, 44], [45, 46, 47], [48, 49, 50] ] this.xtraColIds = [2 for i in range(6)] if this.addXtraEdge: if this.triangleAlt: xtraEs = [42, 44, 45, 47, 48, 50] else: xtraEs = [43, 44, 46, 47, 49, 50] #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(xtraFs) Es.extend(xtraEs) colIds.extend(this.xtraColIds) this.setBaseEdgeProperties(Es = Es) this.setBaseFaceProperties(Fs = Fs, colors = (this.theColors, colIds))
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