PDA

View Full Version : Expression- Simple Trig Function Needed

bradl
07-17-2003, 07:20 PM
Any math/expression geniuses out there give me some help on this on please. I need a light to move up and down it's y axis depending on the camera angle (or any item's angle).

For example when the camera is at 0 Rotation.B I want the light at 0mm Position.Y. When the camera is at 90 I want the light at 650mm, at 180 0mm, at 270 -650mm and 360 0mm.

Sounds complicated but it is actually a sine wave for the Y as the Camera rotates 360 degrees. 90 and 270 are the highs and lows. I would like to use a modifier and have tried a few like channel follower and cycler, but it looks like only and expression will work here.

I appreciate any pointers here for the expression and how to apply it as I have not used them before.

Brad

bradl
07-17-2003, 09:10 PM
Got it working on my own...

FYI:

I started with the expression "sin([Camera.Rotation.B])" in the lights Y position channel, which made the light go up and down wildly with just a few degrees of camera rotation. Figured out that Lightwave must use radians instead of degrees (even though the expression builder points you to a channel that it knows is in degrees?)

To convert degrees to radians you multiply by 2(pi)/360. Couldn't figure out how to use pi directly so put in the numbers. That worked great but the values ranged from 1 to -1 in meters, so I multiplied the whole thing by .645 and I had my range of 645mm to -645mm. Sweet...

It may not be the best way, but it worked! Here is the final expression:

(sin([Camera.Rotation.B]*((2*3.14159)/360)))*.645

richpr
07-17-2003, 10:32 PM
Looks like you could get rid of the multiplation with Pi...

Pi/180 would be the same... Saves a calculation... Or come to think of it use a constant altogether....

Opens up calc.exe...

3.1415926535897932384626433832795 / 180 =
0.017453292519943295769236907684886

The less calculations the better ;)