PDA

View Full Version : non-linear transformation


jaclyn.bill
01-11-2008, 05:43 AM
Dear Users,

I want to change the size of an object using a non-linear function (probably quadratic) over a set period of time - for example, like a balloon inflating which gets quicker towards the end.

Could anyone offer advice on the best way to do this? I'm running a psychology experiment in which this is going to be done many times so I'd like to avoid anything which is computationally slow.

Thank you in advance.

Jaclyn

farshizzo
01-11-2008, 05:19 PM
Here is a sample script that uses cubic interpolation to resize a ball. The animations will start slow and speed up to the end. You can tweak the p1 and p2 parameters of the vizact.sizeTo() command to adjust the midpoints of the cubic spline. Run the script and press the spacebar to toggle between growing and shrinking the ball.import viz
viz.go()

ball = viz.add('ball.wrl',pos=(0,1.8,3))

growAction = vizact.sizeTo([4,4,4],time=1,p1=0.0,p2=0.1)
shrinkAction = vizact.sizeTo([1,1,1],time=1,p1=0.0,p2=0.1)

vizact.onkeydown(' ',ball.runAction,vizact.choice([growAction,shrinkAction]))

jaclyn.bill
01-22-2008, 03:58 AM
thanks for this!

J