예제 #1
1
 def projectVsTo3D(this, Vs4D):
     """
     returns an array of 3D vertices.
     """
     # print "projectTo3D_getVs"
     Vs3D = []
     for v in Vs4D:
         wV = v[3]
         # print "mapping v:", v
         if not Geom3D.eq(this.wCamera, wV):
             scale = this.wCameraDistance / (this.wCamera - wV)
             Vs3D.append([scale * v[0], scale * v[1], scale * v[2]])
         else:
             Vs3D.append([1e256, 1e256, 1e256])
     return Vs3D
예제 #2
0
 def projectVsTo3D(this, Vs4D):
     """
     returns an array of 3D vertices.
     """
     #print "projectTo3D_getVs"
     Vs3D = []
     for v in Vs4D:
         wV = v[3]
         #print "mapping v:", v
         if not Geom3D.eq(this.wCamera, wV):
             scale = this.wCameraDistance / (this.wCamera - wV)
             Vs3D.append([scale * v[0], scale * v[1], scale * v[2]])
         else:
             Vs3D.append([1e256, 1e256, 1e256])
     return Vs3D
예제 #3
0
 def testOrthogonalVectors(R, margin=Geom3D.defaultFloatMargin):
     if not Geom3D.eq(R.e0 * R.e1, 0.0, margin):
         printError("in function _setOrthoMatrix: e0.e1 = ", R.e0 * R.e1, "!= 0")
     if not Geom3D.eq(R.e0 * R.e2, 0.0, margin):
         printError("in function _setOrthoMatrix: e0.e2 = ", R.e0 * R.e2, "!= 0")
     if not Geom3D.eq(R.e0 * R.e3, 0.0, margin):
         printError("in function _setOrthoMatrix: e0.e3 = ", R.e0 * R.e3, "!= 0")
     if not Geom3D.eq(R.e1 * R.e2, 0.0, margin):
         printError("in function _setOrthoMatrix: e1.e2 = ", R.e1 * R.e2, "!= 0")
     if not Geom3D.eq(R.e1 * R.e3, 0.0, margin):
         printError("in function _setOrthoMatrix: e1.e3 = ", R.e1 * R.e3, "!= 0")
     if not Geom3D.eq(R.e2 * R.e3, 0.0, margin):
         printError("in function _setOrthoMatrix: e2.e3 = ", R.e2 * R.e3, "!= 0")
     print "-----resulting matrix-----"
     print R.getMatrix()
     print "--------------------------"
예제 #4
0
 def testOrthogonalVectors(R, margin=Geom3D.defaultFloatMargin):
     if not Geom3D.eq(R.e0 * R.e1, 0.0, margin):
         printError('in function _setOrthoMatrix: e0.e1 = ', R.e0 * R.e1,
                    '!= 0')
     if not Geom3D.eq(R.e0 * R.e2, 0.0, margin):
         printError('in function _setOrthoMatrix: e0.e2 = ', R.e0 * R.e2,
                    '!= 0')
     if not Geom3D.eq(R.e0 * R.e3, 0.0, margin):
         printError('in function _setOrthoMatrix: e0.e3 = ', R.e0 * R.e3,
                    '!= 0')
     if not Geom3D.eq(R.e1 * R.e2, 0.0, margin):
         printError('in function _setOrthoMatrix: e1.e2 = ', R.e1 * R.e2,
                    '!= 0')
     if not Geom3D.eq(R.e1 * R.e3, 0.0, margin):
         printError('in function _setOrthoMatrix: e1.e3 = ', R.e1 * R.e3,
                    '!= 0')
     if not Geom3D.eq(R.e2 * R.e3, 0.0, margin):
         printError('in function _setOrthoMatrix: e2.e3 = ', R.e2 * R.e3,
                    '!= 0')
     print '-----resulting matrix-----'
     print R.getMatrix()
     print '--------------------------'
예제 #5
0
    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
예제 #6
0
    def glDrawSingleRemoveUnscaledEdges(this):
        isScaledDown = not Geom3D.eq(this.c.scale, 1.0, margin=0.001)
        if not this.projectedTo3D:
            # print 'reprojecting...'
            try:
                del this.cell
            except AttributeError:
                pass
            Ns3D = []
            if this.rot4 != None:
                Vs4D = [this.rot4 * v for v in this.Vs]
            # TODO fix Ns.. if needed..
            #    if this.Ns != []:cleanUp
            #        Ns4D = [this.rot4*n for n in this.Ns]
            else:
                Vs4D = [v for v in this.Vs]
            Vs3D = this.projectVsTo3D(Vs4D)
            #for i in range(0, len(this.Es), 2):
            #    v0 = Vs4D[this.Es[i]]
            #    v1 = Vs4D[this.Es[i+1]]
            #    print 'delta v:', v0 - v1
            #    print 'Edge [%d, %d]; len:' % (this.Es[i], this.Es[i+1]), (v1-v0).length()
            #if this.Ns != []:
            #    Ns3D = this.projectVsTo3D(Ns4D)
            # Now project all to one 3D shape. 1 3D shape is chosen, instean of
            # projecting each cell to one shape because of different reasons:
            #  - when drawing transparent faces all the opaqe fae should be
            #    drawn first.
            #  - if drawing the cells per shape, the glVertexPointer should be
            #    called for each cell. (Currently SimpleShape will not call this
            #    function unless the vertices have been changed...
            shapeVs = []
            shapeEs = []
            shapeFs = []
            shapeColIndices = []
            if this.c.draw:
                shapeCols = this.c.col[0]
            else:
                shapeCols = this.f.col[0]
            if this.removeTransparency:
                shapeCols = [c[0:3] for c in shapeCols]
            if this.e.draw and (not isScaledDown or this.e.showUnscaled):
                shapeVs = Vs3D
                shapeEs = this.Es
            # Add a shape with faces for each cell
            for i in xrange(len(this.Cs)):
                # use a copy, since we will filter (v indices will change):
                cellFs = [f[:] for f in this.Cs[i]]
                if this.c.draw:
                    shapeColIndices.extend([this.c.col[1][i] for f in cellFs])
                else:
                    shapeColIndices.extend(this.f.col[1][i])
                # Now cleanup Vs3D
                # TODO
                # if this.e.draw and (not isScaledDown or this.e.showUnscaled):
                # Then shapeVs = Vs3D already, and the code below is all
                # unecessary.
                cellVs = Vs3D[:]
                nrUsed = glue.cleanUpVsFs(cellVs, cellFs)
                # Now attaching to current Vs, will change index:
                offset = len(shapeVs)
                cellFs = [[vIndex + offset for vIndex in f] for f in cellFs]
                # Now scale from gravitation centre:
                if isScaledDown:
                    g = GeomTypes.Vec3([0, 0, 0])
                    sum = 0
                    for vIndex in range(len(cellVs)):
                        g = g + nrUsed[vIndex] * GeomTypes.Vec3(cellVs[vIndex])
                        sum = sum + nrUsed[vIndex]
                    if sum != 0:
                        g = g / sum
                    #print this.name, 'g:', g
                    cellVs = [
                        this.c.scale * (GeomTypes.Vec3(v) - g) + g
                        for v in cellVs
                    ]

                shapeVs.extend(cellVs)
                shapeFs.extend(cellFs)
                # for shapeColIndices.extend() see above
            this.cell = Geom3D.SimpleShape(
                shapeVs,
                shapeFs,
                shapeEs,
                [],  # Vs , Fs, Es, Ns
                (shapeCols, shapeColIndices),
                name='%s_projection' % (this.name))
            this.cell.setVertexProperties(radius=this.v.radius,
                                          color=this.v.col)
            this.cell.setEdgeProperties(radius=this.e.radius,
                                        color=this.e.col,
                                        drawEdges=this.e.draw)
            this.cell.setFaceProperties(drawFaces=this.f.draw)
            this.cell.glInitialised = True  # done as first step in this func
            this.projectedTo3D = True
            this.updateTransparency = False
            if this.e.draw and isScaledDown:
                this.cell.recreateEdges()
                # Don't use, out of performance issues:
                # cellEs = this.cell.getEdgeProperties()['Es']
                # --------------------------
                # Bad performance during scaling:
                # cellEs = this.cell.getEdgeProperties()['Es']
                # this.cell.recreateEdges()
                # cellEs.extend(this.cell.getEdgeProperties()['Es'])
                # -------end bad perf---------
                cellEs = this.cell.Es
                if this.e.showUnscaled:
                    cellEs.extend(this.Es)
                this.cell.setEdgeProperties(Es=cellEs)
        if this.updateTransparency:
            cellCols = this.cell.getFaceProperties()['colors']
            if this.removeTransparency:
                shapeCols = [c[0:3] for c in cellCols[0]]
            else:
                if this.c.draw:
                    shapeCols = this.c.col[0]
                else:
                    shapeCols = this.f.col[0]
            cellCols = (shapeCols, cellCols[1])
            this.cell.setFaceProperties(colors=cellCols)
            this.updateTransparency = False
예제 #7
0
    def printError(str):
        global NrOfErrorsOcurred
        print '***** ERROR while testing *****'
        print ' ', str
        NrOfErrorsOcurred += 1

    v = vec(1, 1, 0, 0)
    w = vec(0, 3, 4, 0)
    z = 0.1 * w
    p = z.isParallel(w)
    if not p:
        printError('in function isParallel')
    t = w.makeOrthogonalTo(v)
    #print 'check if [-3, 3, 8, 0] ==', w
    if not (Geom3D.eq(t.x, -3) and Geom3D.eq(t.y, 3) and Geom3D.eq(t.z, 8)
            and Geom3D.eq(t.w, 0)):
        printError('in function makeOrthogonalTo')
        print '  Expected (-3, 3, 8, 0), got', t

    n = w.normalise()

    # TODO Move some of these tests to GeomTypes, after cgtypes rm, any relevant?

    # check if n is still of type vec and not cgtypes.vec4 (which doesn't have
    # a isParallel)
    if not n.isParallel(w):
        printError('in function isParallel after norm')

    def testOrthogonalVectors(R, margin=Geom3D.defaultFloatMargin):
        if not Geom3D.eq(R.e0 * R.e1, 0.0, margin):
예제 #8
0
    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
예제 #9
0
    def glDrawSingleRemoveUnscaledEdges(this):
        isScaledDown = not Geom3D.eq(this.c.scale, 1.0, margin=0.001)
        if not this.projectedTo3D:
            # print 'reprojecting...'
            try:
                del this.cell
            except AttributeError:
                pass
            Ns3D = []
            if this.rot4 != None:
                Vs4D = [this.rot4 * v for v in this.Vs]
            # TODO fix Ns.. if needed..
            #    if this.Ns != []:cleanUp
            #        Ns4D = [this.rot4*n for n in this.Ns]
            else:
                Vs4D = [v for v in this.Vs]
            Vs3D = this.projectVsTo3D(Vs4D)
            # for i in range(0, len(this.Es), 2):
            #    v0 = Vs4D[this.Es[i]]
            #    v1 = Vs4D[this.Es[i+1]]
            #    print 'delta v:', v0 - v1
            #    print 'Edge [%d, %d]; len:' % (this.Es[i], this.Es[i+1]), (v1-v0).length()
            # if this.Ns != []:
            #    Ns3D = this.projectVsTo3D(Ns4D)
            # Now project all to one 3D shape. 1 3D shape is chosen, instean of
            # projecting each cell to one shape because of different reasons:
            #  - when drawing transparent faces all the opaqe fae should be
            #    drawn first.
            #  - if drawing the cells per shape, the glVertexPointer should be
            #    called for each cell. (Currently SimpleShape will not call this
            #    function unless the vertices have been changed...
            shapeVs = []
            shapeEs = []
            shapeFs = []
            shapeColIndices = []
            if this.c.draw:
                shapeCols = this.c.col[0]
            else:
                shapeCols = this.f.col[0]
            if this.removeTransparency:
                shapeCols = [c[0:3] for c in shapeCols]
            if this.e.draw and (not isScaledDown or this.e.showUnscaled):
                shapeVs = Vs3D
                shapeEs = this.Es
            # Add a shape with faces for each cell
            for i in xrange(len(this.Cs)):
                # use a copy, since we will filter (v indices will change):
                cellFs = [f[:] for f in this.Cs[i]]
                if this.c.draw:
                    shapeColIndices.extend([this.c.col[1][i] for f in cellFs])
                else:
                    shapeColIndices.extend(this.f.col[1][i])
                # Now cleanup Vs3D
                # TODO
                # if this.e.draw and (not isScaledDown or this.e.showUnscaled):
                # Then shapeVs = Vs3D already, and the code below is all
                # unecessary.
                cellVs = Vs3D[:]
                nrUsed = glue.cleanUpVsFs(cellVs, cellFs)
                # Now attaching to current Vs, will change index:
                offset = len(shapeVs)
                cellFs = [[vIndex + offset for vIndex in f] for f in cellFs]
                # Now scale from gravitation centre:
                if isScaledDown:
                    g = GeomTypes.Vec3([0, 0, 0])
                    sum = 0
                    for vIndex in range(len(cellVs)):
                        g = g + nrUsed[vIndex] * GeomTypes.Vec3(cellVs[vIndex])
                        sum = sum + nrUsed[vIndex]
                    if sum != 0:
                        g = g / sum
                    # print this.name, 'g:', g
                    cellVs = [this.c.scale * (GeomTypes.Vec3(v) - g) + g for v in cellVs]

                shapeVs.extend(cellVs)
                shapeFs.extend(cellFs)
                # for shapeColIndices.extend() see above
            this.cell = Geom3D.SimpleShape(
                shapeVs,
                shapeFs,
                shapeEs,
                [],  # Vs , Fs, Es, Ns
                (shapeCols, shapeColIndices),
                name="%s_projection" % (this.name),
            )
            this.cell.setVertexProperties(radius=this.v.radius, color=this.v.col)
            this.cell.setEdgeProperties(radius=this.e.radius, color=this.e.col, drawEdges=this.e.draw)
            this.cell.setFaceProperties(drawFaces=this.f.draw)
            this.cell.glInitialised = True  # done as first step in this func
            this.projectedTo3D = True
            this.updateTransparency = False
            if this.e.draw and isScaledDown:
                this.cell.recreateEdges()
                # Don't use, out of performance issues:
                # cellEs = this.cell.getEdgeProperties()['Es']
                # --------------------------
                # Bad performance during scaling:
                # cellEs = this.cell.getEdgeProperties()['Es']
                # this.cell.recreateEdges()
                # cellEs.extend(this.cell.getEdgeProperties()['Es'])
                # -------end bad perf---------
                cellEs = this.cell.Es
                if this.e.showUnscaled:
                    cellEs.extend(this.Es)
                this.cell.setEdgeProperties(Es=cellEs)
        if this.updateTransparency:
            cellCols = this.cell.getFaceProperties()["colors"]
            if this.removeTransparency:
                shapeCols = [c[0:3] for c in cellCols[0]]
            else:
                if this.c.draw:
                    shapeCols = this.c.col[0]
                else:
                    shapeCols = this.f.col[0]
            cellCols = (shapeCols, cellCols[1])
            this.cell.setFaceProperties(colors=cellCols)
            this.updateTransparency = False
예제 #10
0
    def printError(str):
        global NrOfErrorsOcurred
        print "***** ERROR while testing *****"
        print " ", str
        NrOfErrorsOcurred += 1

    v = vec(1, 1, 0, 0)
    w = vec(0, 3, 4, 0)
    z = 0.1 * w
    p = z.isParallel(w)
    if not p:
        printError("in function isParallel")
    t = w.makeOrthogonalTo(v)
    # print 'check if [-3, 3, 8, 0] ==', w
    if not (Geom3D.eq(t.x, -3) and Geom3D.eq(t.y, 3) and Geom3D.eq(t.z, 8) and Geom3D.eq(t.w, 0)):
        printError("in function makeOrthogonalTo")
        print "  Expected (-3, 3, 8, 0), got", t

    n = w.normalise()

    # TODO Move some of these tests to GeomTypes, after cgtypes rm, any relevant?

    # check if n is still of type vec and not cgtypes.vec4 (which doesn't have
    # a isParallel)
    if not n.isParallel(w):
        printError("in function isParallel after norm")

    def testOrthogonalVectors(R, margin=Geom3D.defaultFloatMargin):
        if not Geom3D.eq(R.e0 * R.e1, 0.0, margin):
            printError("in function _setOrthoMatrix: e0.e1 = ", R.e0 * R.e1, "!= 0")