예제 #1
0
def startOrEnd(curve, point):
    """Determine whether the *point* is close the the start or end point of a curve
    
    """
    start = up.getPosCurvePoint(curve, 0)
    maxV = cmds.getAttr(curve+"_1.maxValue")
    end = up.getPosCurvePoint(curve, maxV)
    dstart = np.linalg.norm(start - point)
    dend = np.linalg.norm(end - point)
    if dstart >= dend:
        return end
    else:
        return start
예제 #2
0
def firstStep(indAnt, curve, vel, isFlat=True, ground=None):
    """Initialise the simulation
    
    This function initialises the settings at the beginning of the simulation.
    
    """
    speed = np.linalg.norm(vel)
    curveStartPoint = up.getPosCurvePoint(curve, 0.01)
    tan = up.getTanCurvePoint(curve, 0.01)
    yAngle = up.getAngle(tan)
    
    comTrajList = []
    comTrajList.append(curveStartPoint)    
       
    triList = []
    newTri = tr.createNewTriTemplate(curveStartPoint, True, yRot=yAngle)    
    newTri = tr.plotTri(newTri, isFlat=isFlat, ground=ground)
    triList.append(newTri)

    
    strideLen = tr.triangleSpeed(speed)
    newTri = tr.createNewTriTemplate(curveStartPoint + strideLen/2*tan, False, yRot=yAngle)    
    newTri = tr.plotTri(newTri, isFlat=isFlat, ground=ground)
    triList.append(newTri)    
    
    diffCOM = np.average(triList[1], 0) - np.average(triList[0], 0)
    curTriRight = triList[1] - diffCOM    
    up.animateBodyLeg(indAnt, curveStartPoint, up.mergeTwoTripod(triList[0], curTriRight))    
    
    jointLTList = []
    jointRTList = []
    jointLT, jointRT = fe.solveJointAngles(curveStartPoint + [0, 0, -0.1], triList[0], triList[1], True)    
    jointLTList.append(jointLT)
    jointRTList.append(jointRT)        
    return comTrajList, triList, jointLTList, jointRTList
예제 #3
0
def getNextCurvePoint(curve, curveArray, curTriCOM, speed):
    """Compute the next point along the curve, with the distance of stride length
    
    """
    strideLen = triangleSpeed(speed)
    lenToP = up.getLenToP(curve)
    indMin = findClosestPointOnCurve(curveArray, curTriCOM)
    minP = cmds.getAttr( curve+'.minValue' )
    maxP = cmds.getAttr( curve+'.maxValue' )
    numInd = len(curveArray)
    pCurve = indMin/numInd*(maxP-minP)    
    pCurve = pCurve + strideLen*lenToP
    nextPos = up.getPosCurvePoint(curve, pCurve)
    nextTan = up.getTanCurvePoint(curve, pCurve)
    nextC = up.getCurvatureCurvePoint(curve, pCurve)
    return np.hstack((nextPos, nextTan, nextC))