def getSubTrajectory(bin1, bin2, point1, point2): xPlane, yPlane, zPlane = bin1.dimensionsShared(bin2) delt = [point2.X - point1.X, point2.Y - point1.Y, point2.Z - point1.Z] initPt = [point1.X, point1.Y, point1.Z] times = [] if len(xPlane) != 0 and delt[0] != 0: for plane in xPlane: xt = (plane - initPt[0]) / delt[0] if 0 < xt < 1: times.append(xt) if len(yPlane) != 0 and delt[1] != 0: for plane in yPlane: yt = (plane - initPt[1]) / delt[1] if 0 < yt < 1: times.append(yt) if len(zPlane) != 0 and delt[2] != 0: for plane in zPlane: zt = (plane - initPt[2]) / delt[2] if 0 < zt < 1: times.append(zt) extraPts = [] times.sort() for i in range(len(times) - 1): midTime = (times[i] + times[i + 1]) / 2 if midTime == times[i]: continue x = initPt[0] + delt[0] * midTime y = initPt[1] + delt[1] * midTime z = initPt[2] + delt[2] * midTime extraPts.append(Point(x, y, z)) return extraPts
def getPointObjects(x, y): pointObjs = [] for idx in range(x.size): a = x[idx] b = y[idx] newObj = Point(a, b, 0) pointObjs.append(newObj) return pointObjs
def getPointObjects(x, y, z=None): pointObjs = [] lastPt = None for idx in range(x.size): a = x[idx] b = y[idx] if z.any(): c = z[idx] else: c = 0 newObj = Point(a, b, c, lastPt) pointObjs.append(newObj) if lastPt: lastPt.setNext(newObj) lastPt = newObj return pointObjs
def getPointObsFromSingleSrc(points): pointObjs = [] for x, y in points: pointObjs.append(Point(float(x), float(y), 0)) return pointObjs
def copyPointObjects(points): retPts = [] for point in points: newPt = Point(point.X, point.Y, point.Z, point.prev, point.nxt) retPts.append(newPt) return retPts
def getPointObject(x, y, z, prevPt=None, nextPt=None): return Point(x, y, z, prevPt)
def getInterestPoints(bin1, bin2, bounds, isX): idx1 = [] idx2 = [] points = [] if isX: idx1.append( bin1.findIndex(Point.Point(bounds.minX, bounds.midY, bounds.minZ))) idx1.append( bin1.findIndex(Point.Point(bounds.maxX, bounds.midY, bounds.minZ))) idx1.append( bin1.findIndex(Point.Point(bounds.minX, bounds.midY, bounds.maxZ))) idx1.append( bin1.findIndex(Point.Point(bounds.maxX, bounds.midY, bounds.maxZ))) idx2.append( bin2.findIndex(Point.Point(bounds.minX, bounds.midY, bounds.minZ))) idx2.append( bin2.findIndex(Point.Point(bounds.maxX, bounds.midY, bounds.minZ))) idx2.append( bin2.findIndex(Point.Point(bounds.minX, bounds.midY, bounds.maxZ))) idx2.append( bin2.findIndex(Point.Point(bounds.maxX, bounds.midY, bounds.maxZ))) else: idx1.append( bin1.findIndex(Point.Point(bounds.midX, bounds.minY, bounds.minZ))) idx1.append( bin1.findIndex(Point.Point(bounds.midX, bounds.maxY, bounds.minZ))) idx1.append( bin1.findIndex(Point.Point(bounds.midX, bounds.minY, bounds.maxZ))) idx1.append( bin1.findIndex(Point.Point(bounds.midX, bounds.maxY, bounds.maxZ))) idx2.append( bin2.findIndex(Point.Point(bounds.midX, bounds.minY, bounds.minZ))) idx2.append( bin2.findIndex(Point.Point(bounds.midX, bounds.maxY, bounds.minZ))) idx2.append( bin2.findIndex(Point.Point(bounds.midX, bounds.minY, bounds.maxZ))) idx2.append( bin2.findIndex(Point.Point(bounds.midX, bounds.maxY, bounds.maxZ))) for idx in idx1: points.extend(bin1.children[idx].points) for idx in idx2: points.extend(bin2.children[idx].points) return points