コード例 #1
0
ファイル: Scenes3D.py プロジェクト: kleopatra999/Orbitit
def getAxis2AxisRotation(a0, a1):
    """Given 2 vectors return the rotation that is needed to transfer 1 into the other.
    """
    # TODO: how to know which angle is taken (if you switch the axes, will you
    # still have to correct angle and axis?)
    vec3Type = type(GeomTypes.Vec3([0, 0, 0]))
    assert (type(a0) == vec3Type) and (type(a1) == vec3Type)
    if a0 == a1:
        # if both axis are in fact the same no roation is needed
        axis = GeomTypes.uz
        angle = 0
    if a0 == -a1:
        # if one axis should be rotated in its opposite axis, handle
        # separately, since the cross product will not work.
        # rotate pi around any vector that makes a straight angle with a0
        a2 = GeomTypes.Vec3([i + 0.5 for i in a1])
        angle = math.pi
        axis = a2.cross(a0)
    else:
        a_0 = a0.normalize()
        a_1 = a1.normalize()
        n = a_0 * a_1
        # because of floats there might be some rounding problems:
        n = min(n, 1.0)
        n = max(n, -1.0)
        angle = math.acos(n)
        axis = a_0.cross(a_1)
    return axis, angle
コード例 #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
ファイル: Geom4D.py プロジェクト: kleopatra999/Orbitit
    def setVertexProperties(this, dictPar=None, **kwargs):
        """
        Set the vertices and how/whether vertices are drawn in OpenGL.

        Accepted are the optional (keyword) parameters:
        - Vs,
        - radius,
        - color.
        - Ns.
        Either these parameters are specified as part of kwargs or as key value
        pairs in the dictionary dictPar.
        If they are not specified (or equal to None) they are not changed.
        See getVertexProperties for the explanation of the keywords.
        The output of getVertexProperties can be used as the dictPar parameter.
        This can be used to copy settings from one shape to another.
        If dictPar is used and kwargs, then only the dictPar will be used.
        """
        if this.dbgTrace:
            print '%s.setVertexProperties(%s,..):' % (this.__class__,
                                                      this.name)
        if dictPar != None or kwargs != {}:
            if dictPar != None:
                dict = dictPar
            else:
                dict = kwargs
            if 'Vs' in dict and dict['Vs'] != None:
                this.Vs = [GeomTypes.Vec4(v) for v in dict['Vs']]
            if 'Ns' in dict and dict['Ns'] != None:
                this.Ns = [GeomTypes.Vec4(n) for n in dict['Ns']]
                #assert len(this.Ns) == len(this.Vs)
            if 'radius' in dict and dict['radius'] != None:
                this.v.radius = dict['radius']
            if 'color' in dict and dict['color'] != None:
                this.v.col = dict['color']
            this.projectedTo3D = False
コード例 #4
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)
コード例 #5
0
ファイル: Scenes3D.py プロジェクト: kleopatra999/Orbitit
 def xy2SphereV(x, y, w, h, R2):
     x, y = x - width / 2, height / 2 - y
     l2 = x * x + y * y
     if l2 < R2:
         spherePos = GeomTypes.Vec3([x, y, math.sqrt(R2 - l2)])
     elif l2 > R2:
         scale = math.sqrt(R2 / l2)
         spherePos = GeomTypes.Vec3([scale * x, scale * y, 0])
     else:  # probably never happens (floats)
         spherePos = GeomTypes.Vec3([x, y, 0])
     return spherePos
コード例 #6
0
 def updateOrientation(this):
     v = this.showGui[this.__AxisGuiIndex].GetVertex()
     if v == GeomTypes.Vec3([0, 0, 0]):
         rot = GeomTypes.E
         this.statusText(
             'Rotation axis is the null-vector: applying identity',
             LOG_INFO)
     else:
         rot = GeomTypes.Rot3(axis=v,
                              angle=Geom3D.Deg2Rad * this.currentAngle)
     try:
         this.shape.setBaseOrientation(rot)
     except AttributeError:
         this.statusText(
             'Apply symmetry first, before pulling the slide-bar', LOG_WARN)
コード例 #7
0
ファイル: Geom4D.py プロジェクト: kleopatra999/Orbitit
    def rotateInStdPlane(this, plane, angle, successive=False):
        """
        Rotate in a plane defined by 2 coordinate axes.

        plane: one of Plane.XY, Plane.XZ, Plane.XW, Plane.YZ,
               Plane.YW, Plane.ZW
        angle: the angle in radials in counter-clockwise direction, while the
               Plane.PQ has a horizontal axis P pointing to the right and a
               vertical axis Q pointing up.
        successive: specify if this is applied on any previous transform, i.e.
                    if this is not a new transforma.
        """
        q0 = None
        if Axis.X & plane: q0 = Vec4([1, 0, 0, 0])
        if Axis.Y & plane:
            if q0 == None:
                q0 = Vec4([0, 1, 0, 0])
            else:
                q1 = Vec4([0, 1, 0, 0])
        if Axis.Z & plane:
            if q0 == None:
                q0 = Vec4([0, 0, 1, 0])
            else:
                q1 = Vec4([0, 0, 1, 0])
        if Axis.W & plane:
            q1 = Vec4([0, 0, 0, 1])
        r = GeomTypes.Rot4(axialPlane=(q0, q1), angle=angle)
        if not successive or this.rot4 == None: this.rot4 = r
        else: this.rot4 = r * this.rot4
        this.projectedTo3D = False
コード例 #8
0
ファイル: Scenes3D.py プロジェクト: kleopatra999/Orbitit
    def OnPaint(this, event):
        if this.dbgTrace:
            print 'Interactive3DCanvas.OnPaint(this,..):'

        def xy2SphereV(x, y, w, h, R2):
            x, y = x - width / 2, height / 2 - y
            l2 = x * x + y * y
            if l2 < R2:
                spherePos = GeomTypes.Vec3([x, y, math.sqrt(R2 - l2)])
            elif l2 > R2:
                scale = math.sqrt(R2 / l2)
                spherePos = GeomTypes.Vec3([scale * x, scale * y, 0])
            else:  # probably never happens (floats)
                spherePos = GeomTypes.Vec3([x, y, 0])
            return spherePos

        dc = wx.PaintDC(this)
        this.SetCurrent(this.context)
        if not this.init:
            this.initGl()
            this.init = True
            this.Moriginal = glGetDoublev(GL_MODELVIEW_MATRIX)
        glPushMatrix()
        this.onPaint()
        glPopMatrix()

        if this.xOrg != 0 or this.yOrg != 0:
            viewPort = glGetIntegerv(GL_VIEWPORT)
            height = viewPort[3] - viewPort[1]
            width = viewPort[2] - viewPort[0]
            D = min(width, height)
            R2 = float(D * D) / 4
            R2 = this.rScale * this.rScale * R2
            newSpherePos = xy2SphereV(this.x, this.y, width, height, R2)
            orgSphere = xy2SphereV(this.xOrg, this.yOrg, width, height, R2)
            ax, an = getAxis2AxisRotation(orgSphere, newSpherePos)
            this.movingRepos = GeomTypes.Rot3(axis=ax,
                                              angle=an) * this.modelRepos
            glLoadMatrixd(this.Moriginal)
            glScalef(this.currentScale, this.currentScale, this.currentScale)
            save, GeomTypes.eqFloatMargin = GeomTypes.eqFloatMargin, 1.0e-14
            angle = Geom3D.Rad2Deg * this.movingRepos.angle()
            axis = this.movingRepos.axis()
            GeomTypes.eqFloatMargin = save
            #print 'rotate', angle, axis
            glRotatef(angle, axis[0], axis[1], axis[2])

        if this.z != this.zBac:
            dZ = this.z - this.zBac
            # map [min, max] onto [0, 2]
            # dZ' = (2/(max-min)) dZ + 1
            #pStr = '%f ->' % dZ
            dZ = dZ * this.zScaleFactor + 1.0
            this.currentScale = dZ * this.currentScale
            #print '%s %f' % (pStr, dZ)
            glScalef(dZ, dZ, dZ)

        glFlush()
        this.SwapBuffers()
コード例 #9
0
ファイル: GeomGui.py プロジェクト: kleopatra999/Orbitit
 def onFloat(this, e):
     #ctrlId = e.GetId()
     vEvent = VectorUpdatedEvent(myEVT_VECTOR_UPDATED, this.GetId())
     vEvent.SetEventObject(this)
     vEvent.SetVector(
         GeomTypes.Vec4([
             this.__v[0].GetValue(), this.__v[1].GetValue(),
             this.__v[2].GetValue(), this.__v[3].GetValue()
         ]))
     this.__v[this.__ctrlIdIndex].GetEventHandler().ProcessEvent(vEvent)
コード例 #10
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)
コード例 #11
0
ファイル: GeomGui.py プロジェクト: kleopatra999/Orbitit
    def GetSelected(this):
        """returns a symmetry instance"""
        sym = this.getSymmetryClass(applyOrder=False)
        setup = {}
        for i, gui in zip(range(len(this.oriGuis)), this.oriGuis):
            inputType = sym.initPars[i]['type']
            if inputType == 'vec3':
                v = gui.GetVertex()
                if v != GeomTypes.Vec3([0, 0, 0]):
                    setup[sym.initPars[i]['par']] = v
            elif inputType == 'int':
                v = gui.GetValue()
                setup[sym.initPars[i]['par']] = v
        #print 'GetSelected; setup:', setup
        #print 'class:', sym
        sym = sym(setup=setup)

        return sym
コード例 #12
0
import Geom3D
import GeomTypes
import math

Vs = [
	GeomTypes.Vec3([ 1,  1,  1]),
	GeomTypes.Vec3([-1,  1,  1]),
	GeomTypes.Vec3([-1, -1,  1]),
	GeomTypes.Vec3([ 1, -1,  1]),
	GeomTypes.Vec3([ 1,  1, -1]),
	GeomTypes.Vec3([-1,  1, -1]),
	GeomTypes.Vec3([-1, -1, -1]),
	GeomTypes.Vec3([ 1, -1, -1]),
	GeomTypes.Vec3([ 1,  1, -2]),
	GeomTypes.Vec3([.5,  1,  1]),
]

Fs = [
	[0, 4, 8],      # just a line
        [0, 9, 1, 2, 3],# first part on line, cannot be used to calc face normal
	[0, 3, 7, 4],
	[1, 0, 4, 5],
	[2, 1, 5, 6],
	[3, 2, 6, 7],
	[7, 6, 5, 4]
]

shape = Geom3D.SimpleShape(Vs = Vs, Fs = Fs)
コード例 #13
0
# along with this program; if not,
# check at http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# or write to the Free Software Foundation,
#--------------------------------------------------------------------

import wx
import math
import rgb
import Heptagons
import GeomTypes
import Geom3D
import Scenes3D

Title = 'Equilateral Heptagons Tetrahedron'

vec = lambda x, y, z: GeomTypes.Vec3([x, y, z])

V2  = math.sqrt(2)
hV2 = 1.0/V2
tV3 = 1.0/math.sqrt(3)

class Shape(Heptagons.EqlHeptagonShape):
    def __init__(this):
        Heptagons.EqlHeptagonShape.__init__(this,
            directIsometries = [
                    GeomTypes.E,
                    GeomTypes.Hx,
                    GeomTypes.Hy,
                    GeomTypes.Hz
                ],
            name = 'EglHeptS4A4'
コード例 #14
0
import GeomTypes
import Geom3D
import isometry
shape = Geom3D.IsometricShape(
    Vs = [
        GeomTypes.Vec3([1.0, 1.0, 1.0]),
        GeomTypes.Vec3([-1.0, 1.0, 1.0]),
        GeomTypes.Vec3([-1.0, -1.0, 1.0]),
        GeomTypes.Vec3([1.0, -1.0, 1.0]),
        GeomTypes.Vec3([1.0, 1.0, -1.0]),
        GeomTypes.Vec3([-1.0, 1.0, -1.0]),
        GeomTypes.Vec3([-1.0, -1.0, -1.0]),
        GeomTypes.Vec3([1.0, -1.0, -1.0])
    ],
    Fs = [
        [0, 1, 2, 3],
        [0, 3, 7, 4],
        [1, 0, 4, 5],
        [2, 1, 5, 6],
        [3, 2, 6, 7],
        [7, 6, 5, 4]
    ],
    Es = [0, 1, 1, 2, 2, 3, 0, 3, 3, 7, 4, 7, 0, 4, 4, 5, 1, 5, 5, 6, 2, 6, 6, 7],
    colors = [
        ([[0.99609400000000003, 0.83984400000000003, 0.0]], []),
        ([[0.13281200000000001, 0.54296900000000003, 0.13281200000000001]], []),
        ([[0.54296900000000003, 0.0, 0.0]], []),
        ([[0.0, 0.74609400000000003, 0.99609400000000003]], []),
        ([[0.54296900000000003, 0.0, 0.0]], []),
        ([[0.13281200000000001, 0.54296900000000003, 0.13281200000000001]], []),
        ([[0.0, 0.74609400000000003, 0.99609400000000003]], []),
コード例 #15
0
import GeomTypes
import Geom3D
import isometry
shape = Geom3D.CompoundShape(simpleShapes=[
    Geom3D.SimpleShape(Vs=[
        GeomTypes.Vec3([1.0, 1.0, 1.0]),
        GeomTypes.Vec3([-1.0, 1.0, 1.0]),
        GeomTypes.Vec3([-1.0, -1.0, 1.0]),
        GeomTypes.Vec3([1.0, -1.0, 1.0]),
        GeomTypes.Vec3([1.0, 1.0, -1.0]),
        GeomTypes.Vec3([-1.0, 1.0, -1.0]),
        GeomTypes.Vec3([-1.0, -1.0, -1.0]),
        GeomTypes.Vec3([1.0, -1.0, -1.0]),
        GeomTypes.Vec3([1.0, 1.0, -2.0]),
        GeomTypes.Vec3([0.5, 1.0, 1.0])
    ],
                       Fs=[[0, 1, 2, 3], [0, 3, 7, 4], [1, 0, 4, 5],
                           [2, 1, 5, 6], [3, 2, 6, 7], [7, 6, 5, 4]],
                       Es=[],
                       colors=([[0.99609400000000003, 0.0,
                                 0.0]], [0, 0, 0, 0, 0, 0]),
                       name="SimpleShape"),
    Geom3D.SimpleShape(Vs=[
        GeomTypes.Vec3([0.0, 0.0, 2.0]),
        GeomTypes.Vec3([2.0, 0.0, 0.0]),
        GeomTypes.Vec3([0.0, 2.0, 0.0]),
        GeomTypes.Vec3([-2.0, 0.0, 0.0]),
        GeomTypes.Vec3([0.0, -2.0, 0.0]),
        GeomTypes.Vec3([0.0, 0.0, 2.0])
    ],
                       Fs=[[0, 1, 2], [0, 2, 3], [0, 3, 4], [0, 4, 1],
コード例 #16
0
ファイル: Geom4D.py プロジェクト: kleopatra999/Orbitit
    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
コード例 #17
0
    def setV(this):
        Vt = [0, this.top, 0]
        Vb = [0, -this.tail, 0]
        Vl = [-this.side, 0, 0]
        Vr = [this.side, 0, 0]
        tuple = Heptagons.Kite2Hept(Vl, Vt, Vr, Vb)
        if tuple == None: return
        h0, h1, h2, h3, h4, h5, h6 = tuple[0]

        #
        #              3 0'
        #
        #
        #        6'            1'
        #
        #
        #   2           +           0
        #
        #      5'                2'
        #
        #
        #
        #          4'        3'
        #
        #
        #               1
        #
        this.kiteVs = [
            GeomTypes.Vec3([Vr[0], Vr[1], Vr[2]]),
            GeomTypes.Vec3([Vb[0], Vb[1], Vb[2]]),
            GeomTypes.Vec3([Vl[0], Vl[1], Vl[2]]),
            GeomTypes.Vec3([Vt[0], Vt[1], Vt[2]])
        ]
        d = 1e-4
        this.heptaVs = [
            GeomTypes.Vec3([Vt[0], Vt[1], Vt[2] + d]),
            GeomTypes.Vec3([h1[0], h1[1], h1[2] + d]),
            GeomTypes.Vec3([h2[0], h2[1], h2[2] + d]),
            GeomTypes.Vec3([h3[0], h3[1], h3[2] + d]),
            GeomTypes.Vec3([h4[0], h4[1], h4[2] + d]),
            GeomTypes.Vec3([h5[0], h5[1], h5[2] + d]),
            GeomTypes.Vec3([h6[0], h6[1], h6[2] + d])
        ]
        # try to set the vertices array.
        # the failure occurs at init since showKite and showHepta don't exist
        try:
            Vs = []
            print 'this.showKite', this.showKite, 'this.showHepta', this.showHepta
            if this.showKite:
                Vs.extend(this.kiteVs)
            if this.showHepta:
                Vs.extend(this.heptaVs)
            for v in Vs:
                print v
            print '==============='
            this.setVertexProperties(Vs=Vs)
        except AttributeError:
            pass
コード例 #18
0
    T64: '64 Triangles',
}


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))


# get the col faces array by using a similar shape here, so it is calculated
# only once
useIsom = isometry.A4()
egShape = Geom3D.IsometricShape(Vs=[
    GeomTypes.Vec3([0, 0, 1]),
    GeomTypes.Vec3([0, 1, 1]),
    GeomTypes.Vec3([1, 1, 1])
],
                                Fs=[[0, 1, 2]],
                                directIsometries=useIsom,
                                unfoldOrbit=True)
#colStabiliser = isometry.C2(setup = {'axis': [0.0, 1.0, 0.0]})
#colStabiliser = isometry.C2(setup = {'axis': [0.0, 0.0, 1.0]})
useSimpleColours = False
colStabiliser = isometry.C2(setup={'axis': [1.0, 0.0, 0.0]})
colQuotientSet = useIsom / colStabiliser
if useSimpleColours:
    useRgbCols = [
        rgb.gray95,
        rgb.gray80,
コード例 #19
0
ファイル: Scenes3D.py プロジェクト: kleopatra999/Orbitit
 def __init__(this, v0, v1, v2):
     this.v = [GeomTypes.Vec3(v0), GeomTypes.Vec3(v1), GeomTypes.Vec3(v2)]
     this.N = None
コード例 #20
0
ファイル: GeomGui.py プロジェクト: kleopatra999/Orbitit
 def GetValue(this):
     return GeomTypes.Vec4([
         this.__v[0].GetValue(), this.__v[1].GetValue(),
         this.__v[2].GetValue(), this.__v[3].GetValue()
     ])
コード例 #21
0
import GeomTypes
import Geom3D
import isometry
shape = Geom3D.IsometricShape(
    Vs=[
        GeomTypes.Vec3([1.0, 1.0, 1.0]),
        GeomTypes.Vec3([-1.0, 1.0, 1.0]),
        GeomTypes.Vec3([-1.0, -1.0, 1.0]),
        GeomTypes.Vec3([1.0, -1.0, 1.0]),
        GeomTypes.Vec3([1.0, 1.0, -1.0]),
        GeomTypes.Vec3([-1.0, 1.0, -1.0]),
        GeomTypes.Vec3([-1.0, -1.0, -1.0]),
        GeomTypes.Vec3([1.0, -1.0, -1.0]),
    ],
    Fs=[
        [0, 1, 2, 3],
        [0, 3, 7, 4],
        [1, 0, 4, 5],
        [2, 1, 5, 6],
        [3, 2, 6, 7],
        [7, 6, 5, 4],
    ],
    Es=[
        0, 1, 1, 2, 2, 3, 0, 3, 3, 7, 4, 7, 0, 4, 4, 5, 1, 5, 5, 6, 2, 6, 6, 7
    ],
    colors=[
        ([[0.99609400000000003, 0.83984400000000003, 0.0]], []),
        ([[0.13281200000000001, 0.54296900000000003,
           0.13281200000000001]], []),
        ([[0.54296900000000003, 0.0, 0.0]], []),
        ([[0.0, 0.74609400000000003, 0.99609400000000003]], []),
コード例 #22
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],
    }),
コード例 #23
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 = {
コード例 #24
0
    only_hepts:		'Just Heptagons',
}

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],
コード例 #25
0
ファイル: GeomGui.py プロジェクト: kleopatra999/Orbitit
 def GetVertex(this):
     return GeomTypes.Vec3([
         this.__v[0].GetValue(),
         this.__v[1].GetValue(),
         this.__v[2].GetValue(),
     ])
コード例 #26
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
コード例 #27
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
コード例 #28
0
ファイル: GeomGui.py プロジェクト: kleopatra999/Orbitit
 def getVector(this, i):
     return GeomTypes.Vec3([
         this.__v[i][0].GetValue(),
         this.__v[i][1].GetValue(),
         this.__v[i][2].GetValue(),
     ])
コード例 #29
0
import Geom3D
import GeomTypes
import math

Vs = [
	GeomTypes.Vec3([ 1,  1,  1]),
	GeomTypes.Vec3([-1,  1,  1]),
	GeomTypes.Vec3([-1, -1,  1]),
	GeomTypes.Vec3([ 1, -1,  1]),
	GeomTypes.Vec3([ 1,  1, -1]),
	GeomTypes.Vec3([-1,  1, -1]),
	GeomTypes.Vec3([-1, -1, -1]),
	GeomTypes.Vec3([ 1, -1, -1]),
	GeomTypes.Vec3([ 1,  1, -2]),
	GeomTypes.Vec3([.5,  1,  1]),
]

Fs = [
        [0, 1, 2, 3],
	[0, 3, 7, 4],
	[1, 0, 4, 5],
	[2, 1, 5, 6],
	[3, 2, 6, 7],
	[7, 6, 5, 4]
]

shape0 = Geom3D.SimpleShape(Vs = Vs, Fs = Fs)

Vs = [
	GeomTypes.Vec3([ 0,  0,  2]),
	GeomTypes.Vec3([ 2,  0,  0]),
コード例 #30
0
import GeomTypes
import Geom3D
import isometry
shape = Geom3D.SimpleShape(Vs=[
    GeomTypes.Vec3([1.0, 1.0, 1.0]),
    GeomTypes.Vec3([-1.0, 1.0, 1.0]),
    GeomTypes.Vec3([-1.0, -1.0, 1.0]),
    GeomTypes.Vec3([1.0, -1.0, 1.0]),
    GeomTypes.Vec3([1.0, 1.0, -1.0]),
    GeomTypes.Vec3([-1.0, 1.0, -1.0]),
    GeomTypes.Vec3([-1.0, -1.0, -1.0]),
    GeomTypes.Vec3([1.0, -1.0, -1.0]),
    GeomTypes.Vec3([1.0, 1.0, -2.0]),
    GeomTypes.Vec3([0.5, 1.0, 1.0])
],
                           Fs=[[0, 4, 8], [0, 9, 1, 2, 3], [0, 3, 7, 4],
                               [1, 0, 4, 5], [2, 1, 5, 6], [3, 2, 6, 7],
                               [7, 6, 5, 4]],
                           Es=[],
                           colors=([[0.99609400000000003, 0.0,
                                     0.0]], [0, 0, 0, 0, 0, 0, 0]),
                           name="SimpleShape")