コード例 #1
0
def transformObject(v, vn, chScale, chObjAz, chObjDisplacement, chObjRotation,
                    targetPosition):

    scaleMat = geometry.Scale(x=chScale[0], y=chScale[1], z=chScale[2])[0:3,
                                                                        0:3]
    chRotAzMat = geometry.RotateZ(a=-chObjAz)[0:3, 0:3]
    transformation = ch.dot(chRotAzMat, scaleMat)
    invTranspModel = ch.transpose(ch.inv(transformation))

    objDisplacementMat = computeHemisphereTransformation(
        chObjRotation, 0, chObjDisplacement, np.array([0, 0, 0]))

    newPos = objDisplacementMat[0:3, 3]

    vtransf = []
    vntransf = []

    for mesh_i, mesh in enumerate(v):
        vtransf = vtransf + [
            ch.dot(v[mesh_i], transformation) + newPos + targetPosition
        ]
        # ipdb.set_trace()
        # vtransf = vtransf + [v[mesh_i] + chPosition]
        vndot = ch.dot(vn[mesh_i], invTranspModel)
        vndot = vndot / ch.sqrt(ch.sum(vndot**2, 1))[:, None]
        vntransf = vntransf + [vndot]
    return vtransf, vntransf, newPos
コード例 #2
0
def transformObject(v, vn, chScale, chObjAz, chPosition):
    #print ('utils.py:16  transformObject')
    #print ('v', type(v))
    #import ipdb
    #ipdb.set_trace()
    if chScale.size == 1:
        scaleMat = geometry.Scale(x=chScale[0], y=chScale[0],
                                  z=chScale[0])[0:3, 0:3]
    elif chScale.size == 2:
        scaleMat = geometry.Scale(x=chScale[0], y=chScale[0],
                                  z=chScale[1])[0:3, 0:3]
    else:
        scaleMat = geometry.Scale(x=chScale[0], y=chScale[1],
                                  z=chScale[2])[0:3, 0:3]
    chRotAzMat = geometry.RotateZ(a=chObjAz)[0:3, 0:3]
    chRotAzMatX = geometry.RotateX(a=0)[0:3, 0:3]

    # transformation = scaleMat
    transformation = ch.dot(ch.dot(chRotAzMat, chRotAzMatX), scaleMat)
    invTranspModel = ch.transpose(ch.inv(transformation))

    vtransf = []
    vntransf = []
    for mesh_i, mesh in enumerate(v):
        vtransf = vtransf + [ch.dot(v[mesh_i], transformation) + chPosition]
        vndot = ch.dot(vn[mesh_i], invTranspModel)
        vndot = vndot / ch.sqrt(ch.sum(vndot**2, 1))[:, None]
        vntransf = vntransf + [vndot]
    return vtransf, vntransf
コード例 #3
0
ファイル: utils.py プロジェクト: tpalczew/InfoGAN-CR
def transformObjectFull(v, vn, chScale, chObjAz, chObjAx, chObjAz2,
                        chPosition):
    if chScale.size == 1:
        scaleMat = geometry.Scale(x=chScale[0], y=chScale[0],
                                  z=chScale[0])[0:3, 0:3]
    elif chScale.size == 2:
        scaleMat = geometry.Scale(x=chScale[0], y=chScale[0],
                                  z=chScale[1])[0:3, 0:3]
    else:
        scaleMat = geometry.Scale(x=chScale[0], y=chScale[1],
                                  z=chScale[2])[0:3, 0:3]

    chRotAzMat = geometry.RotateZ(a=chObjAz)[0:3, 0:3]
    chRotAxMat = geometry.RotateX(a=-chObjAx)[0:3, 0:3]
    chRotAzMat2 = geometry.RotateZ(a=chObjAz2)[0:3, 0:3]

    transformation = ch.dot(
        ch.dot(ch.dot(chRotAzMat, chRotAxMat), chRotAzMat2), scaleMat)

    invTranspModel = ch.transpose(ch.inv(transformation))

    vtransf = []
    vntransf = []
    for mesh_i, mesh in enumerate(v):
        vtransf = vtransf + [ch.dot(v[mesh_i], transformation) + chPosition]
        vndot = ch.dot(vn[mesh_i], invTranspModel)
        vndot = vndot / ch.sqrt(ch.sum(vndot**2, 1))[:, None]
        vntransf = vntransf + [vndot]
    return vtransf, vntransf