vary expression-driven spinning
I've written an expression (partly using code I've found elsewhere) to animate a group of 5 spheres so that they can either circle around a null or follow it with a delay between them. Generally it works well but when I try to animate the circling speed it doesn't animate smoothly. Between two keyframes, it sometimes appears to reverse, slow down, or speed up wildly when it should be gradually gaining speed. I think this is because the trigonetry doesn't increase linearly and so one frame doesn't progress as expected.
My code is as follows:
ballnum=5;
nullpos=thisComp.layer("Null 1").transform.position;
radius = thisComp.layer("expression sliders").effect("radius")("Slider");
startAngle = degreesToRadians(ballnum*72); // yourStartAngle in degrees
T = thisComp.layer("expression sliders").effect("Rotation speed")("Slider"); // speed in rotations per second;
angularSpeed = 2 * Math.PI*T;
xt = nullpos[0] + radius * Math.cos(time*angularSpeed + startAngle);
yt = nullpos[1] + radius * Math.sin(time*angularSpeed + startAngle);
pos1=[xt, yt];
follow=thisComp.layer("expression sliders").effect("circle to follow position")("Slider");
delay=thisComp.layer("expression sliders").effect("delay amount")("Slider")/25;
delayA=(ballnum-1)*delay
pos2=nullpos.valueAtTime(time-delayA);
ease(follow,0,100,pos1,pos2)
The last part of the expression allows me to ease between the balls rotating around the null and following it with a delay.
Would be very grateful for any help on this one.
John
