Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Exit Search

- Home
- After Effects
- Discussions
- How do I move a layer at a specific angle using an...

- How do I move a layer at a specific angle using an...

0

/t5/after-effects-discussions/how-do-i-move-a-layer-at-a-specific-angle-using-an-expression/td-p/13238134
Sep 30, 2022
Sep 30, 2022

Copy link to clipboard

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

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

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;
angle = degreesToRadians(a);
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

/t5/after-effects-discussions/how-do-i-move-a-layer-at-a-specific-angle-using-an-expression/m-p/13238137#M212153
Sep 30, 2022
Sep 30, 2022

Copy link to clipboard

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

Community guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/after-effects-discussions/how-do-i-move-a-layer-at-a-specific-angle-using-an-expression/m-p/13238161#M212157
Oct 01, 2022
Oct 01, 2022

Copy link to clipboard

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.

Community guidelines

Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

Community Expert
,

LATEST
/t5/after-effects-discussions/how-do-i-move-a-layer-at-a-specific-angle-using-an-expression/m-p/13238176#M212159
Oct 01, 2022
Oct 01, 2022

Copy link to clipboard

Copied

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;
angle = degreesToRadians(a);
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.

Community guidelines

Resources

Troubleshooting FAQs

After Effects Community Recap

Getting started with After Effects

Copyright © 2023 Adobe. All rights reserved.