def thickenate(prisms,
               thicknessMap={
                   0: 1.4,
                   1: 1.3,
                   2: 1.2,
                   3: 1.1,
                   4: 1.0,
                   5: 0.9,
                   6: 0.8,
                   7: 0.7
               },
               minThickness=0.6):
    for count, prism in enumerate(prisms):
        thickness = minThickness
        if count > 0:
            layer_count = int(math.log(count, 2))
        else:
            layer_count = 0
        if layer_count in thicknessMap.keys():
            thickness = thicknessMap[layer_count]
        bMinusA = geometry.getNormalVector(prism[1], prism[0])
        cMinusA = geometry.getNormalVector(prism[2], prism[0])
        normal = geometry.normalizeVector(geometry.cross(bMinusA, cMinusA))
        for point in prism:
            for coord in xrange(3):
                point[coord] = point[coord] - normal[coord] * thickness / 2.0
        newPoints = []
        for point in prism:
            newPoint = []
            for coord in xrange(3):
                newPoint.append(point[coord] + normal[coord] * thickness)
            newPoints.append(newPoint)
        prism.extend(newPoints)
  u(ux + vy + wz )(1 - cos theta) + x cos theta + (- wy + vz) sin theta
  v(ux + vy + wz )(1 - cos theta) + ycos theta + (wx - uz) sin theta
  w(ux +  vy + wz )(1 - cos theta) + z cos theta + (- vx + uy) sin theta

  use normal vector UVW, rotate theta around this, use every point in pointList

  '''
  vecU, vecV, vecW = vector
  cosTheta = math.cos(theta)
  sinTheta = math.sin(theta)
  newPts = []
  for point in pointList:
    ptX, ptY, ptZ = point
    uxvywz = vecU * ptX + vecV * ptY + vecW * ptZ
    newX = vecU * uxvywz * (1 - cosTheta) + ptX * cosTheta + (
        -vecW * ptY + vecV * ptZ) * sinTheta
    newY = vecV * uxvywz * (1 - cosTheta) + ptY * cosTheta + (
        vecW * ptX - vecU * ptZ) * sinTheta
    newZ = vecW * uxvywz * (1 - cosTheta) + ptZ * cosTheta + (
        -vecV * ptX + vecU * ptY) * sinTheta
    newPts.append((newX, newY, newZ))
  return newPts

#following is for rudimentary testing
if __name__ == "__main__":
  points = [[1., 2., 3.], [3., 2., 3.], [-2, 0., 1.]]
  vecRot = geometry.normalizeVector(
      (random.random(), random.random(), random.random()))
  theta = random.random()
  print projectPoints(points, vecRot, theta)
    pdbCode = string.split(os.path.split(onePdb)[-1], '.')[0]
    points = pdbD.coords
    try:
        os.mkdir(os.path.join(databaseDir, pdbCode))
    except OSError:
        pass  # directory exists, fine
    for vector in xrange(3):
        for thetaTen in xrange(0, 62, 3):
            vecX, vecY, vecZ = 0., 0., 0.
            if vector == 0:
                vecX = 1.
            elif vector == 1:
                vecY = 1.
            elif vector == 2:
                vecZ = 1.
            normalVec = geometry.normalizeVector((vecX, vecY, vecZ))
            theta = thetaTen / 10.
            name = string.join(
                [str(vecX), str(vecY),
                 str(vecZ), str(theta)], '.')
            projectedPts = project.projectPointsOnto2D(points, normalVec,
                                                       theta)
            mins, maxs = project.size2dSquare(projectedPts, radius)
            matrix = project.make2dMap(projectedPts, radius, mins, maxs, size)
            pngfile = open(
                os.path.join(databaseDir, pdbCode,
                             pdbCode + '.' + name + '.png'), 'wb')
            pngwriter = png.Writer(size, size, greyscale=True, bitdepth=1)
            pngwriter.write(pngfile, matrix)
            pngfile.close()
'''
  pdbCode = string.split(os.path.split(onePdb)[-1], '.')[0]
  points = pdbD.coords
  try:
    os.mkdir(os.path.join(databaseDir, pdbCode))
  except OSError:
    pass  # directory exists, fine
  for vector in xrange(3):
    for thetaTen in xrange(0, 62, 3):
      vecX, vecY, vecZ = 0., 0., 0.
      if vector == 0:
        vecX = 1.
      elif vector == 1:
        vecY = 1.
      elif vector == 2:
        vecZ = 1.
      normalVec = geometry.normalizeVector((vecX, vecY, vecZ))
      theta = thetaTen / 10.  
      name = string.join([str(vecX), str(vecY), str(vecZ), str(theta)], '.')
      projectedPts = project.projectPointsOnto2D(points, normalVec, theta)
      mins, maxs = project.size2dSquare(projectedPts, radius)
      matrix = project.make2dMap(projectedPts, radius, mins, maxs, size)
      pngfile = open(
          os.path.join(
              databaseDir, pdbCode, pdbCode + '.' + name + '.png'), 'wb')
      pngwriter = png.Writer(size, size, greyscale=True, bitdepth=1)
      pngwriter.write(pngfile, matrix)
      pngfile.close()



'''