Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
    def setV(this):
        # input this.h
        St = this.h / (2*math.sqrt(2*Cq)*this.h - Cq)
        #
        #                  2
        #           __..--'-_
        #      1 -''    .    _"- 3
        #         \       _-'
        #          \   _-'
        #           \-'
        #           0
        #
        #    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,      St,     St/2),
                vec(-Rl[0],   Rl[1],  Rl[2])     # 3
            ]

        # add heptagons
        H = HalfTurn(Vs[3])
        this.errorStr = ''
        if 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
            #print v
            # 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 pentagon.
            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 = ''
        # rotate vt by a half turn, IsoscelesTriangleV NOT auto updated.
        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)]
        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
Пример #5
0
    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={
Пример #6
0
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)
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 = {
Пример #7
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