ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Expression help needed

FAQ   •   VIEW ALL
 Expression help needed on Feb 10, 2009 at 6:42:16 pm

Not quite sure how to explain this so I made a diagram.

http://foxbot.tv/temp/expression_diagram.gif

I would like to add an expression to null c so that where ever I move points a and b, c is equal to the distance between a and b and also at the same angle. I can figure it out mathematically but have no idea how to translate it into a working expression. Any help is greatly appreciated.

 Re: Expression help neededon Feb 10, 2009 at 7:16:36 pm

Try this:

A = thisComp.layer("a");
B = thisComp.layer("b");

a = A.toWorld(A.anchorPoint);
b = B.toWorld(B.anchorPoint);
2*b - a

Dan

 Re: Expression help neededon Feb 10, 2009 at 7:22:47 pm

Worked liked a charm. Makes complete sense once you write it out. Thank you so much.

 Re: Expression help neededon Feb 13, 2009 at 4:58:26 pm

I now have a new problem. What If I don't want C to equal the distance betweem A and B. I want to be able to move C around but keep it at the correct angle?

 Re: Expression help neededon Feb 13, 2009 at 5:51:09 pm

One way would be to add a slider to c and change the expression to this:

slider = effect("Slider Control")("Slider");

A = thisComp.layer("a");
B = thisComp.layer("b");

a = A.toWorld(A.anchorPoint);
b = B.toWorld(B.anchorPoint);
b + (b-a)*slider

You might want to adjust the slider range so that it only goes from 0 to 5 instead of 0 to 100.

Dan