I'm using quaternion for continuous/infinite rotation because if i used euler, it would a) just increase the rotation value forever or b) if i limited it to 360° then the transition from 359 to 0, would make it spin the other way. If there's another way to do this, I'm open to trying. I'm not sure which part of my python script is slowing things down, but perhaps its the quat.slerp method and would be better off avoiding quaternions.

My script cook time when it's running is 2.5ms. I'll post the .tox and code here. In the tox, all you need to do is change the value in the "new_index" CHOP and it will make the script run.

- Code: Select all
`maxCharCount = int(op('maxCharCount')[0])`

#set up the first two quaternions in the list

quatList = [

tdu.Quaternion(tdu.Vector(0, 0, 0)), tdu.Quaternion(tdu.Vector(181, 0, 0))

]

#set up the first two rotations

rotList = ['rot0','rot1']

#figure out how many remaining elements we need to add to the list

remaining = maxCharCount - 2;

#automatically fill in the rest of the lists

for x in range(remaining):

value = 180 - ((x + 0.5) * (180/remaining))

quatList.append(tdu.Quaternion(tdu.Vector(value, 0, 0)))

rotList.append('rot' + str(x + 2))

qTable = op('table1')

def onValueChange(channel, sampleIndex, val, prev):

#the transition time

t = val % 1

for x in range(maxCharCount):

currentIndex = (math.floor(val) + x) % maxCharCount

nextIndex = (math.floor(val) + x + 1) % maxCharCount

#inerpolating between quaternions

rotList[x] = quatList[currentIndex].slerp(quatList[nextIndex], t)

#writing them to the table

qTable[x,0] = rotList[x].x

qTable[x,1] = rotList[x].y

qTable[x,2] = rotList[x].z

qTable[x,3] = rotList[x].w

return