ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Constraint movement along X, Y and Z axis

FAQ   •   VIEW ALL Constraint movement along X, Y and Z axis on Jun 21, 2019 at 9:45:04 amLast Edited By Rowan de Geus on Jun 21, 2019 at 10:09:06 am

Hello reader,

I am struggling creating an expression to constrain movement of a layer to a certain angle. I found this isometric expression which works great:

pos = transform.position;
x = effect("X Movement")(1);
z = effect("Z Movement")(1);
y = effect("Y Movement")(1);
[x*Math.sqrt(3) + z*Math.sqrt(3) + pos, -x + z + y + pos];

But how can I adjust this to match angles of 190 and 140?

EDIT: Found it for the X axis (thanks Dan):

x = effect("X Movement")("Slider");
a = 190;
y = -x*Math.tan(degreesToRadians(a));
value + [x,y]

But how to adjust this so Z has an angle of 140?

 Return to posts index Re: Constraint movement along X, Y and Z axison Jun 21, 2019 at 11:07:43 amLast Edited By Rowan de Geus on Jun 21, 2019 at 11:41:17 am

Got it:

pos = transform.position;
x = effect("X Movement")(1);
z = effect("Z Movement")(1);
y = effect("Y Movement")(1);
a1 = 190;
a2 = 40;
[x + z + pos, -x*Math.tan(degreesToRadians(a1)) + z*Math.tan(degreesToRadians(a2)) + y + pos];

 Return to posts index Re: Constraint movement along X, Y and Z axison Jun 28, 2019 at 5:05:26 pm

Thank you for sharing your solution!

- The Great Szalam
(The 'Great' stands for 'Not So Great, in fact, Extremely Humble')

No trees were harmed in the creation of this message, but several thousand electrons were mildly inconvenienced.

 Return to posts index