-
Finding a loop point in an Expression
I am using the following on position
xAmp = 30; //height of undulations (pixels)
xFreq = .8; //undulations per second
xSpeed = 350; //speed of wave (pixels per second)wl = xSpeed/xFreq; //wavelength (pixels)
phaseOffset = ((position[0]%wl)/wl)*2*Math.PI;
y = xAmp*Math.sin(2*Math.PI*xFreq*time + phaseOffset);swayAmp = 50; //amplitude of sway
swayFreq = 2; //frequency of sway
x = swayAmp * Math.sin(time * swayFreq);value + [x,y]
and the following on rotation
xFreq = .5; //undulations per second
xSpeed = 150; //speed of wave (pixels per second)
damping = 12; //undulation damping factorwl = xSpeed/xFreq; //wavelength (pixels)
phaseOffset = ((position[0]%wl)/wl)*2*Math.PI;
theta = Math.atan(Math.cos(2*Math.PI*xFreq*time + phaseOffset));
radiansToDegrees(theta)/damping;Is there any way to make these expressions loopable? I would like the position and rotation to come back to the original starting point so that it makes a perfect loop cycle.
Any help would be greatly appreciated!