Beispiel #1
0
def getAvgPoints(pts, pointNames, indexRange):
    points = np.zeros((len(pointNames), 3))
    for i in indexRange:
        points += _getPoints(pts, pointNames, i)

    points = points/float(len(indexRange))
    pointDict = {}
    for i in range(len(pointNames)):
        pointDict[pointNames[i]] = points[i]
    return pointDict
Beispiel #2
0
def main():
    markerNames = ['LASIS', 'RASIS', 'LPSIS', 'RPSIS', 'SACR']
    # markerNames = ['LGTRO', 'FLTHI', 'LTHI', 'LLEK']
    pelvisPoints = parsePointFile('Subject005Trial08.txt', markerNames)

    mass = 35.8 # Trunk weight in kg
    totalHeight = 1.7 # meters
    height = 0.289*totalHeight # meters
    width = 0.2295*totalHeight # meters
    thickness = 0.15 # meters
    inertiaMatrix = getInertiaMatrix(mass, width, height, thickness)

    timeIndicies = range(400, 1200)

    rotationMatrix = np.zeros((4,4,len(timeIndicies)))
    points0 = _getPoints(pelvisPoints, markerNames, 0)
    for i in range(len(timeIndicies)):
        timeIndex = timeIndicies[i]
        points1 = _getPoints(pelvisPoints, markerNames, timeIndex)
        rotationMatrix[:,:,i] = soderSvd(points0, points1)

    rotationMatrix = filterData(rotationMatrix)

    rotationMatrix = rotationMatrix[:,:,200:801]

    angularVelocities = np.zeros((rotationMatrix.shape[2], 3))
    for i in range(1, rotationMatrix.shape[2]-1):
        angularVelocities[i] = getAngularVelocity(rotationMatrix[:,:,i-1],
                                                  rotationMatrix[:,:,i],
                                                  rotationMatrix[:,:,i+1])
    angularAccelerations = getAngularAcceleration(angularVelocities)

    moments = np.zeros_like(angularAccelerations)
    term1 = np.zeros_like(angularAccelerations)
    term2 = np.zeros_like(angularAccelerations)
    for i in range(len(angularAccelerations)):
        moments[i], term1[i], term2[i] = getMoments(inertiaMatrix, angularVelocities[i], angularAccelerations[i])
    return angularVelocities, angularAccelerations, moments, term1, term2