View Full Version : Urget help needed with an expression

11-06-2005, 04:00 AM
need some urgent help with an expression.

The scene involves an object that oscilates through an angle of about 45 degrees (easy enough). The object is stationary at first (for x amount of frames) but needs to speed up linearly until it reaches a certain speed (a) at frame (b). The amplitude of the oscilations however needs to be constant throughout its movement (45 degrees). There is no damping and phase starts at 0. My crude diagram below shows kind of what I am after. Any help at all would be apreciated. I've tried LW expression builder but the presets only cater for damped and regular oscilations.



11-06-2005, 11:43 AM
You could probably do it with a nested conditional expression for the three phases of the curve: idle phase, ramp-up phase and running phase, but the expression is going to get pretty convoluted.

I'd recommend using a simpler expression with a Null as a "frequency controller". Something along the lines of:

sin(Frame * 20 * [FrequencyController_Null.Position.Y] * 3.141/180.0)

Where "FrequencyController_Null" is the exact name of the Null, the 20 is a frequency multiplier, and 3.141/180.0 is converting to radians.

You'd then hold the Null at zero until you want the oscillation to start, set up a linear curve on the Y position during the ramp-up phase, and a constant height during the running phase.

Good luck!

P.S. As you probably already know, the Expression parser is *very* unforgiving about case and spelling. Make sure your Null name is spelled exactly (including case) and the Position.Y channel name has the precise spelling and case.

P.P.S: This expression will give you a range from -1 to +1. If you want a different range, put a multiplier in front of the sin() function, and add a value to shift it up or down.

11-06-2005, 02:26 PM
:) wow your a genius I would never have thought of doing it like that ..its exactly the motion I was after. Plus by making the line curved I can now have exponential increases in speed.