ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Camera positioning expression

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Akane Hiraoka
Camera positioning expression
on Aug 21, 2018 at 10:35:23 pm

Hello,

I don't even know where to begin, but I have to make amends to the camera animation that someone else had created. Camera movements are controlled by the following expression. I have 6 navigation points to adjust at the moment but I have to add 7 more points to animate the entire scene, but it's just too difficult for me to get my head around, if anyone can figure it out or explain to me the following expression will be super super appreciated!

rSt=thisComp.layer("EDIT").effect("StartRadius")("ADBE Slider Control-0001");
rMid=thisComp.layer("EDIT").effect("MiddleRadius")("ADBE Slider Control-0001");
rEnd=thisComp.layer("EDIT").effect("EndRadius")("ADBE Slider Control-0001");

SA=thisComp.layer("EDIT").effect("StartAngle")("ADBE Angle Control-0001");
EA=thisComp.layer("EDIT").effect("EndAngle")("ADBE Angle Control-0001");

m1=thisComp.layer("L3").effect("m1")("ADBE Slider Control-0001");
m2=thisComp.layer("L3").effect("m2")("ADBE Slider Control-0001");
m3=thisComp.layer("L3").effect("m3")("ADBE Slider Control-0001");
m4=thisComp.layer("L3").effect("m4")("ADBE Slider Control-0001");
m5=thisComp.layer("L3").effect("m5")("ADBE Slider Control-0001");
m6=thisComp.layer("L3").effect("m6")("ADBE Slider Control-0001");

timeNew=thisComp.layer("Marker").effect("Marker_0-5000")("ADBE Slider Control-0001");

tN=ease(timeNew, m1, m6, [0], [1]);

Rad=Math.pow(1-tN, 2)*rSt+2*tN*(1-tN)*rMid+Math.pow(tN, 2)*rEnd;

P1=thisComp.layer("P1").transform.position;
P2=thisComp.layer("P2").transform.position;
P3=thisComp.layer("P3").transform.position;
P4=thisComp.layer("P4").transform.position;
P5=thisComp.layer("P5").transform.position;
P6=thisComp.layer("P6").transform.position;

P0=[P1[0]+Rad, P1[1]];
P02=[P6[0]-Rad, P6[1]];



t11=easeIn(timeNew, m1, m2, [0], [1]);
t22=linear(timeNew, m2, m3, [0], [1]);
t33=linear(timeNew, m3, m4, [0], [1]);
t44=linear(timeNew, m4, m5, [0], [1]);
t55=easeOut(timeNew, m5, m6, [0], [1]);

if(timeNew= m2 && timeNew=m3 && timeNew=m4 && timeNew=m5) t5=1 else t5=0;

t=t11*t1+t22*t2+t33*t3+t44*t4+t55*t5;



pM2=(P1+P2+P3+P4+P5+P6)/6;

n1=thisComp.layer("P1").transform.position;
n2=thisComp.layer("P2").transform.position;
n3=thisComp.layer("P3").transform.position;
n4=thisComp.layer("P4").transform.position;
n5=thisComp.layer("P5").transform.position;
n6=thisComp.layer("P6").transform.position;

L1=length(P0, pM2);
L2=length(P0, P1);
L3=length(P1, pM2);

L12=length(P02, pM2);
L22=length(P02, P6);
L32=length(P6, pM2);

q=(Math.pow(L2, 2)+Math.pow(L3, 2)-Math.pow(L1, 2))/(2*L2*L3);
a=Math.acos(q);
a2=radiansToDegrees(a);
a3=ease(a2, 0, 180, [135+SA], [45+SA]);

q22=(Math.pow(L22, 2)+Math.pow(L32, 2)-Math.pow(L12, 2))/(2*L22*L32);
a22=Math.acos(q22);
a222=radiansToDegrees(a22);
a322=ease(a222, 180, 0, [45+EA], [135+EA]);
u=ease(tN, 0, 1, [a3], [a322]);

a4=degreesToRadians(u);
r1=[n1[0]+Rad*Math.cos(a4), n1[1]+Rad*Math.sin(a4)];
r2=[n2[0]+Rad*Math.cos(a4), n2[1]+Rad*Math.sin(a4)];
r3=[n3[0]+Rad*Math.cos(a4), n3[1]+Rad*Math.sin(a4)];
r4=[n4[0]+Rad*Math.cos(a4), n4[1]+Rad*Math.sin(a4)];
r5=[n5[0]+Rad*Math.cos(a4), n5[1]+Rad*Math.sin(a4)];
r6=[n6[0]+Rad*Math.cos(a4), n6[1]+Rad*Math.sin(a4)];

r12=(r1+r2)/2;
r22=(r2+r3)/2;
r32=(r3+r4)/2;
r42=(r4+r5)/2;
r52=(r5+r6)/2;
r61=r52;
r21=2*r2-r22;
r31=2*r3-r32;
r41=2*r4-r42;
r51=2*r5-r52;

rv11=(1-t11);
rv21=Math.pow(rv11, 2);
rv31=Math.pow(rv11, 3);
tp21=Math.pow(t11, 2);
tp31=Math.pow(t11, 3);
rv12=(1-t22);
rv22=Math.pow(rv12, 2);
rv32=Math.pow(rv12, 3);
tp22=Math.pow(t22, 2);
tp32=Math.pow(t22, 3);
rv13=(1-t33);
rv23=Math.pow(rv13, 2);
rv33=Math.pow(rv13, 3);
tp23=Math.pow(t33, 2);
tp33=Math.pow(t33, 3);
rv14=(1-t44);
rv24=Math.pow(rv14, 2);
rv34=Math.pow(rv14, 3);
tp24=Math.pow(t44, 2);
tp34=Math.pow(t44, 3);
rv15=(1-t55);
rv25=Math.pow(rv15, 2);
rv35=Math.pow(rv15, 3);
tp25=Math.pow(t55, 2);
tp35=Math.pow(t55, 3);
rY1=rv31*r1+3*t11*rv21*r12+3*tp21*rv11*r21+tp31*r2;
rY2=rv32*r2+3*t22*rv22*r22+3*tp22*rv12*r31+tp32*r3;
rY3=rv33*r3+3*t33*rv23*r32+3*tp23*rv13*r41+tp33*r4;
rY4=rv34*r4+3*t44*rv24*r42+3*tp24*rv14*r51+tp34*r5;
rY5=rv35*r5+3*t55*rv25*r52+3*tp25*rv15*r61+tp35*r6;

r=t1*rY1+t2*rY2+t3*rY3+t4*rY4+t5*rY5;


Return to posts index

Kalleheikki Kannisto
Re: Camera positioning expression
on Aug 22, 2018 at 1:55:02 pm
Last Edited By Kalleheikki Kannisto on Aug 22, 2018 at 1:56:07 pm

I'm not going to attempt to interpret the code, but from the looks of it, you need to add the new points (6 through 13) in a number of locations in the code. I marked the points where I saw you'd have to add code, using the same calculations but updating the variable names for each.

"... through..." means all values between following the same logic. You want to keep track of, on a piece of paper, the different variable namings. In one spot the points 6-12 are added instead 6-13. I guess the last interval is handled differently.

Theoretically this could work.


rSt=thisComp.layer("EDIT").effect("StartRadius")("ADBE Slider Control-0001");
rMid=thisComp.layer("EDIT").effect("MiddleRadius")("ADBE Slider Control-0001");
rEnd=thisComp.layer("EDIT").effect("EndRadius")("ADBE Slider Control-0001");

SA=thisComp.layer("EDIT").effect("StartAngle")("ADBE Angle Control-0001");
EA=thisComp.layer("EDIT").effect("EndAngle")("ADBE Angle Control-0001");

m1=thisComp.layer("L3").effect("m1")("ADBE Slider Control-0001");
m2=thisComp.layer("L3").effect("m2")("ADBE Slider Control-0001");
m3=thisComp.layer("L3").effect("m3")("ADBE Slider Control-0001");
m4=thisComp.layer("L3").effect("m4")("ADBE Slider Control-0001");
m5=thisComp.layer("L3").effect("m5")("ADBE Slider Control-0001");
m6=thisComp.layer("L3").effect("m6")("ADBE Slider Control-0001");
m7=... through
m13= ...


timeNew=thisComp.layer("Marker").effect("Marker_0-5000")("ADBE Slider Control-0001");

tN=ease(timeNew, m1, m13, [0], [1]);

Rad=Math.pow(1-tN, 2)*rSt+2*tN*(1-tN)*rMid+Math.pow(tN, 2)*rEnd;

P1=thisComp.layer("P1").transform.position;
P2=thisComp.layer("P2").transform.position;
P3=thisComp.layer("P3").transform.position;
P4=thisComp.layer("P4").transform.position;
P5=thisComp.layer("P5").transform.position;
P6=thisComp.layer("P6").transform.position;
P7=... through
P13=...



P0=[P1[0]+Rad, P1[1]];
P02=[P13[0]-Rad, P13[1]];



t11=easeIn(timeNew, m1, m2, [0], [1]);
t22=linear(timeNew, m2, m3, [0], [1]);
t33=linear(timeNew, m3, m4, [0], [1]);
t44=linear(timeNew, m4, m5, [0], [1]);
t55=easeOut(timeNew, m5, m6, [0], [1]);
t66 =... through
t1313 = ...


if(timeNew= m2 && timeNew=m3 && timeNew=m4 && timeNew=m5 && timeNew=m6 through timeNew =m12) t5=1 else t5=0;

t=t11*t1+t22*t2+t33*t3+t44*t4+t55*t5+t65*t6 through t1212*t12;



pM2=(P1+P2+P3+P4+P5+P6+P7 though P13)/13;

n1=thisComp.layer("P1").transform.position;
n2=thisComp.layer("P2").transform.position;
n3=thisComp.layer("P3").transform.position;
n4=thisComp.layer("P4").transform.position;
n5=thisComp.layer("P5").transform.position;
n6=thisComp.layer("P6").transform.position;
n7=... through
n13= ....

L1=length(P0, pM2);
L2=length(P0, P1);
L3=length(P1, pM2);

L12=length(P02, pM2);
L22=length(P02, P13);
L32=length(P13, pM2);

q=(Math.pow(L2, 2)+Math.pow(L3, 2)-Math.pow(L1, 2))/(2*L2*L3);
a=Math.acos(q);
a2=radiansToDegrees(a);
a3=ease(a2, 0, 180, [135+SA], [45+SA]);

q22=(Math.pow(L22, 2)+Math.pow(L32, 2)-Math.pow(L12, 2))/(2*L22*L32);
a22=Math.acos(q22);
a222=radiansToDegrees(a22);
a322=ease(a222, 180, 0, [45+EA], [135+EA]);
u=ease(tN, 0, 1, [a3], [a322]);

a4=degreesToRadians(u);
r1=[n1[0]+Rad*Math.cos(a4), n1[1]+Rad*Math.sin(a4)];
r2=[n2[0]+Rad*Math.cos(a4), n2[1]+Rad*Math.sin(a4)];
r3=[n3[0]+Rad*Math.cos(a4), n3[1]+Rad*Math.sin(a4)];
r4=[n4[0]+Rad*Math.cos(a4), n4[1]+Rad*Math.sin(a4)];
r5=[n5[0]+Rad*Math.cos(a4), n5[1]+Rad*Math.sin(a4)];
r6=[n6[0]+Rad*Math.cos(a4), n6[1]+Rad*Math.sin(a4)];
r7=... through
r13=...


note: this will make a conflict with variable naming r12, so that variable name need to be changed here

r12=(r1+r2)/2;
r22=(r2+r3)/2;
r32=(r3+r4)/2;
r42=(r4+r5)/2;
r52=(r5+r6)/2;
r62=... through
r132=...


r61=r52;
r21=2*r2-r22;
r31=2*r3-r32;
r41=2*r4-r42;
r51=2*r5-r52;
r61= through
r131=...


rv11=(1-t11);
rv21=Math.pow(rv11, 2);
rv31=Math.pow(rv11, 3);
tp21=Math.pow(t11, 2);
tp31=Math.pow(t11, 3);
rv12=(1-t22);
rv22=Math.pow(rv12, 2);
rv32=Math.pow(rv12, 3);
tp22=Math.pow(t22, 2);
tp32=Math.pow(t22, 3);
rv13=(1-t33);
rv23=Math.pow(rv13, 2);
rv33=Math.pow(rv13, 3);
tp23=Math.pow(t33, 2);
tp33=Math.pow(t33, 3);
rv14=(1-t44);
rv24=Math.pow(rv14, 2);
rv34=Math.pow(rv14, 3);
tp24=Math.pow(t44, 2);
tp34=Math.pow(t44, 3);
rv15=(1-t55);
rv25=Math.pow(rv15, 2);
rv35=Math.pow(rv15, 3);
tp25=Math.pow(t55, 2);
tp35=Math.pow(t55, 3);
rv16=(1-t66);
rv26=Math.pow(rv16, 2);
rv36=Math.pow(rv16, 3);
tp26=Math.pow(t66, 2);
tp36=Math.pow(t66, 3); ... through

tp313=Math.pow(t1313, 3);


rY1=rv31*r1+3*t11*rv21*r12+3*tp21*rv11*r21+tp31*r2;
rY2=rv32*r2+3*t22*rv22*r22+3*tp22*rv12*r31+tp32*r3;
rY3=rv33*r3+3*t33*rv23*r32+3*tp23*rv13*r41+tp33*r4;
rY4=rv34*r4+3*t44*rv24*r42+3*tp24*rv14*r51+tp34*r5;
rY5=rv35*r5+3*t55*rv25*r52+3*tp25*rv15*r61+tp35*r6;
rY6=... through
rY13=...


r=t1*rY1+t2*rY2+t3*rY3+t4*rY4+t5*rY5+t6*rY6 through t13*rY13;

Kalleheikki Kannisto
Senior Graphic Designer


Return to posts index

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