ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Convert rotation direction into a percentage?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Sam Klejwa
Convert rotation direction into a percentage?
on Nov 7, 2014 at 7:31:31 pm

Hey guys!

So, I'm doing a day to night animated timelapse, one that speeds up exponentially as the comp goes on.

I have a sun and moon image parented to a null, which rotates, bringing them above the horizon line at 0 and 180 degrees respectively.

I also have two backgrounds, a day and night, one on top of the other.

I need to figure out an expression so that when the null is at 0 degrees, the opacity of the night layer is 0, and when it's at 180 degrees, the opacity is at 100

This works for a half rotation cycle with: thisComp.layer("Day and Night").transform.rotation/180*100

But, I need it to continue to work as the null rotates many many times...

Any suggestions?


Return to posts index

Dan Ebberts
Re: Convert rotation direction into a percentage?
on Nov 7, 2014 at 10:05:41 pm

It might be something like this:

r = thisComp.layer("Day and Night").transform.rotation;
linear(r%360,0,180,0,100)


Dan



Return to posts index

Sam Klejwa
Re: Convert rotation direction into a percentage?
on Nov 7, 2014 at 10:13:54 pm

Close, though then there's this sudden jerk when you go from 359 degrees to 360 (it fades up but doesnt fade down)


Return to posts index


Bruno Borges Kieling
Re: Convert rotation direction into a percentage?
on Oct 7, 2019 at 6:57:54 pm

I know this is a very old post. But for anybody is the same problem. For this action you need a sin expression. A simple one can resolve.

a=effect("Angle Control")("Angle") // link this to the angle you want to turn into percent
v=180 // the value you want that the percent have 100 value
c=v*64/100 // this is a variant for the percent always be 100 for the set angle
Math.sin(a/c)*100

This work only with + values.
If you need to work with - values, than you gonna need to add a if expression to works.

a=effect("Angle Control")("Angle");
b=180;
c=b*64/100;
if(a>=0)
{Math.sin(a/c)*100}
else
{Math.sin(-a/c)*100}

This is a little messy but works.


Return to posts index

Bruno Borges Kieling
Re: Convert rotation direction into a percentage?
on Oct 7, 2019 at 7:43:23 pm

a=effect("Angle Control")("Angle"); // LINK to angle
b=180; // limit angle for the 100 value in percent
c=b*64/100; // only a variant, do not change
Math.abs(Math.sin(a/c)*100)


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]