-
Controlling an offset position with an angle slider.
Hey smart people,
I’m wondering if there’s an elegant way to controlling a layers position using angles & magnitudes as opposed to cartesian coordinates.
And if not, is there a breakdown somewhere of how turn angle inputs into x/y outputs. From my floundering research thus far noticed there’s a lot of radian conversions & if/then statements for the 4 quadrants but I haven’t been able to parse it beyond that.
For reference, Dan Ebberts code here almost does what I’m trying to figure out, but I can’t quite deconstruct it in order to control the distance of the offset.
Thanks,
EDIT: After a bit more searching I came across GrayMachine’s polar coordinate code. It took a bit of tinkering but I got it to work for myself. However, set the resting position of the layer (that is, the position when the Distance1 slider was 0) at 971,971. Subtracted 11 from 2 lines of code & that managed to work, but I don’t really know /why/.
d = thisComp.layer(“Master”).effect(“Distance1”)(“Slider”)
a = thisComp.layer(“Master”).effect(“Angle Control”)(“Angle”)angle = a;
length = d;
aRad =degreesToRadians( angle – 90);
x=d*Math.cos(aRad)-11;
y=d*Math.sin(aRad)-11;
add(position, [x, y]);