## Adobe Support Community

• Global community
• Language:
• Deutsch
• English
• Español
• Français
• Português
• 日本語コミュニティ
Dedicated community for Japanese speakers
• 한국 커뮤니티
Dedicated community for Korean speakers
Exit Search
• How do I move a layer at a specific angle using an...

# How do I move a layer at a specific angle using an expression

Community Expert ,
Sep 30, 2022 Sep 30, 2022

Copied

I've been fiddling with this one for several hours, and it's time to humbly ask for help. I know the basics; if you know the length of the opposite side of a right triangle and the angle, you can calculate the adjacent side's value. If I have a center layer and an Expression Control slider for the hypotenuse length or radius of a circle from the center and have an Angle Control for angle, I should be able to calculate the X and Y values for the target layer. The sin and cos of the angle time the hypotenuse don't work. I'm stuck. Any suggestions would be appreciated. I can't even get the first 90º to work. If anyone knows, it's Dan Ebberts.

TOPICS
Expressions , How to , Resources

Views

65

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more ## 2 Correct answers

Community Expert , Oct 01, 2022 Oct 01, 2022

Rick,

I'm having trouble picturing which point you're trying to calculate. Do you maybe just need to convert your angle from the degrees of your angle control to radians required by Math.sin() and Math.cos()? If that's not it, just post a sketch and we'll get it.

Community Expert , Oct 01, 2022 Oct 01, 2022

Thank you Dan Ebberts.  I figured it out. Once I converted the angle to radians, everything worked fine. Here's the final expression:

``````h = effect("h")("Slider");
a = effect("a")("Angle") - 90;
x = h * Math.cos(angle);
y = h * Math.sin(angle);
c = thisComp.layer("Center").position;
[x, y]`````` This was the research part of a much larger project that involves distributing a bunch of 3D layers in a sphere. It's a complicated model of a galaxy. I only have angle and dista

... 3 Replies 3
LEGEND ,
Sep 30, 2022 Sep 30, 2022

Copied

Law of cosines.

https://en.wikipedia.org/wiki/Law_of_cosines

You calculate the second angle (the third will always be 90, anyway) and then can calculate the lengths of all sides.

Mylenium

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more Community Expert ,
Oct 01, 2022 Oct 01, 2022

Copied

Rick,

I'm having trouble picturing which point you're trying to calculate. Do you maybe just need to convert your angle from the degrees of your angle control to radians required by Math.sin() and Math.cos()? If that's not it, just post a sketch and we'll get it.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more Community Expert ,
Oct 01, 2022 Oct 01, 2022

Copied

LATEST

Thank you Dan Ebberts.  I figured it out. Once I converted the angle to radians, everything worked fine. Here's the final expression:

``````h = effect("h")("Slider");
a = effect("a")("Angle") - 90;
x = h * Math.cos(angle);
y = h * Math.sin(angle);
c = thisComp.layer("Center").position;
[x, y]`````` This was the research part of a much larger project that involves distributing a bunch of 3D layers in a sphere. It's a complicated model of a galaxy. I only have angle and distance data to work with.

Must have been tired. I did not think about the degrees to radians modifier until I quit for the night. As soon as that was in there, I have all I need to make a bunch of planets orbit around a star in orbits that are not symmetrical.   