Orbits in After Effects

I'm new to After Effects and I might be asking about obvious stuff, but I searched this site and elsewhere and can't find an answer.

Basically I want to orbit some points in a setup similar to the Sun - Earth - Moon (Sun is static, Earth goes around the Sun, and the Moon goes around the Earth), and I need each moving point to have its position change over time so that I can parent other stuff to them.

I'm trying to animate this graphic:

I've got the epicycle (the small circle) to rotate around point T (Terre), while V (Venus) is rotating on the epicycle. I have a beam between T and the center of the epicycle (C), but I would also need to add a beam between C and Venus.

I can get Venus to rotate on the epicycle either by making it an ellipse on it's own layer and then parenting it to the epicycle; or I can add it as another ellipse on the same shape layer as the epicycle, making V rotate with the epicycle. But in both cases the position of Venus remains invariable, so the beam can't follow.

How do I make point V rotate on the epicycle such that its own position changes over time allowing me to add a beam between it and the center of the epicycle?

I'm confused by all the different Position parameters, if I create V as an ellipse on its own shape layer there'll be 3 different position parameters and none if them will change over time if V is parented to the epicycle. I've also tried alt-pick-whipping these 3 to the position of the epicycle with no luck.

• Are all your elements based on shape layers or do you use masks aswell? Specifically the epicycle, did you draw that or is it from the ellipse tool? – timonsku May 12 '14 at 23:09
• Hey, thanks for replying! All my elements are based on shape layers. However, I also tried making a solid (opacity 0) and then added a circular mask on it with the size of the epicycle (which is a shape layer). Then I parented this solid to the epicycle, so it would follow its position. Then I tried to copy the "mask path" keyframe from this solid to Venus - hoping that it would thus rotate according to the circular mask and also follow the epicycle that's rotating around T. But it doesn't work, everything goes nuts when I try this. – Paul Lupascu May 12 '14 at 23:34
• I'm sure I can help you with that, paths in After Effects can be a bit tedious sometimes. Though the answer would take some time to write and its long past midnight here. I will write something up for you tomorrow if someone else hasn't already helped you. – timonsku May 12 '14 at 23:40
• Are you worried about the impact of the position in the orbit on the center of gravity of the objects going around the center? If not, simple nested compositions could probably do it pretty easily. – AJ Henderson May 13 '14 at 2:15
• Hi AJ, thanks for replying. I don't need to take into account the center of gravity, so I will try this. As I understand, you're suggesting that I create each movement in a separate composition? So I'll have one comp with Venus rotating on the epicycle, and then another comp with the epicycle rotating on its own orbit around T? Is that what you're recommending? Thanks! – Paul Lupascu May 13 '14 at 12:54

Ok, it's relatively straightforward using some expressions. But then again isn't everything?

Assuming you've got your original rotating beam layer, your epicycle layer which is parented to the original beam, and your Venus layer parented to that. You need to find the co-ordinates of the center of the Venus layer, relative to the Composition, in order to draw a beam to it.

Well you could work it out trigonometrically I'm sure, but it's way too late and I've been into the Irish Single Malt, so I'm not going to go there. Luckily there's a handy expression that does the job: toComp(point). What it does is find the composition co-ordinates of a point on a layer.

First we apply a Point Control effect Effects>Expression Controls>Point Control to the Venus layer, we'll use the toComp expression to set its value. But before that, make sure the Anchor Point property of the Venus layer is showing – we'll need it in a second.

Now to apply an expression to the point control alt/opt-click the stopwatch on the Point property of that effect. In the expressions editor that opens up type toComp( and then drag the expression pick-whip to the Anchor Point property to fill in the value Transfrom.AnchorPoint. You can type it, but it's case sensitive and not at all forgiving of typos. Then close the brackets: ) it should now read toComp(transform.anchorPoint).

So now you have a point that tells you where exactly the Venus Layer's anchor point is in the comp. Using an expression you could plug this straight into the End Point property of the Beam effect, but I'm allergic to the beam effect, I prefer to use shape layers, because vectors.

So I make a new rectangular shape layer with the stroke I want, and no fill, and I set all the transforms to 0. The size of the rectangle path is going to be the length between the start of the original beam, and the value of the Point Control point, AKA the position of Venus. You can do this by getting the square root of the sum of the squares of the X and Y offsets, but that's a bit 6th century BC, instead we'll use the handy expression length(point1, point2). And we'll set the height to 0, so that it draws a line.

So on the rectangle shape layer, in the Contents>Rectangle 1>Rectangle Path 1 Property we'll use this expression:

origin=thisComp.layer("origin");
venus=thisComp.layer("venus")
beamlength=length(origin.transform.position, venus.effect("Point Control")("Point"));
[beamlength,0]


layer origin is the original beam. You could do it all on one line, but it would be hella ugly:

[length(thisComp.layer("origin").transform.position,thisComp.layer("venus").effect("Point Control")("Point")),0]


Beauty is truth.

Since by default the rectangle tool draws rectangles around a central point we need to offset it. In the Contents>Rectangle 1>Rectangle Path 1>Position Property (not the layer's position property, that should be the same as the original beam, or the shape's Contents>Rectangle 1>Transform: Rectangle 1>position property, that should be 0,0) we offset it by half the width, so that the rectangle's left edge is always at the origin, thus : content("Rectangle 1").content("Rectangle Path 1").size/2 (did you notice that we're dividing a vector by a scalar? 100 Nerd points to you if you did.)

Now we've got a beam that is the right length, but we need to rotate it. Thank you and good night Pythagoras, hello Mr Aryabhata. Since we know the rise and the run, we can find the angle using Atan(rise/run). But there's some problems: when the run is negative Atan will return a positive value, and whenever the run is 0 the expression will crash. And lastly Math.atan returns a result in Radians, so we need to convert it to degrees. So we have to turn a relatively simple expression into this monster, which goes on the Contents>Rectangle 1>Transform: Rectangle 1>Rotation Property:

s=thisComp.layer("venus").effect("Point Control")("Point");
o=thisComp.layer("origin").transform.position;
run=s[0]-o[0];
rise=s[1]-o[1];
if (run==0){
if (rise>0) //pointing straight up
{-90;}
else //pointing straight down
{90;}
} else{
if (run>0){
} else {
}
}


this is how my beam layer looks:

and below is the whole comp. I've used shape layers for everything and driven them all by expressions as is my wont, if you want to have a look at it, it's here.

• Stack Exchange suggest I shouldn't say thanks here, but I want to thank you very much for your thorough explanations and I hope you'll see my reply. I have already found a solution for my question thanks to the help of the other responders, but I have bookmarked your post and I will surely use it next time. Thank you very much once again for taking the time to this, I'm very impressed. You can take a look at what I've done here. – Paul Lupascu Feb 7 '15 at 13:42

I would probably start from the smallest orbit and work my way out. If you adjust the anchor point for each object that is rotating, a simple rotation keyframe should make it rotate around the center.

Once you have the smallest thing rotating, you include that composition in another composition and adjust the anchor point similarly to make it rotate around the center of the new composition.

If you need oblong orbits, you can also use a path instead and animate it along the path.

You can keep nesting them indefinitely for as many nestings as you need. It isn't a 100% accurate simulation since the actual orbital mechanics are a bit more complicated, but it gives a simple simulation of them and can easily support various periods for each part.

• Thanks a lot AJ! I will try this tonite, I'm sure it will be helpful. – Paul Lupascu May 14 '14 at 10:30
• Thanks again AJ. I can use this trick to create a composition where the beam is static, and then rotate the composition; so I don't need to have the position of the ellipse Venus. – Paul Lupascu May 18 '14 at 21:27

You probably want to work with Motion Paths here. Though for those to work you need beziere based shapes and not parametric shapes like you have right now. The differences is that parametric shapes (coming from the shape tool (rectangle, ellipse etc.)) are defined by numeric parameters (the part with the first position value in your image). Bezier shapes have points with handles to define the shape, what you get when you draw with the pen tool.

You can use the shape tool to make bezier based shapes and I would recommend that you redo the few shapes you have and simply copy over the settings and keyframes from you existing shapes. To make a bezier shape with the shape tool simply hold down the alt key while creating the shape. Then simply click on the "Path" object in the "Path x" dropdown of your shape.

Then copy that with Ctrl+C and paste it onto the position of your Venus shape. Either the layers position (the one on the bottom of your screenshot) or the position of the shape itself (the middle one in your screenshot). That will create keyframes for the current outer path of your shape. Then parent the Venus shape to the epicycle shape and the Venus will rotate along the epicycle and move with it. If the Venus is a bit off you can offset the position with either the layer position or the shape position depending on which one you chose to paste the motion path on. This will result in an animation like this:

I hope thats what you were after. If you want to extend the length of the motion path animation just select all the keyframes and drag the last one with the alt key pressed.

To make a connection between Venus and the Epicycle center you have to work with an expression. The easiest way would be to create a null that you parent to Venus and then move the Nulls Anchor Point to the center of the Venus (work from the start frame of the animation to make your life easier). Then apply this expression to one end of the beam effect:

L = thisComp.layer("Null 1");
L.toWorld(L.anchorPoint)


"Null 1" being the name of you Null object. This expression gives you the actual global position of your null. If you just use the position value it wont move as these values aren't actually animated right now. We basically get what After Effects is doing in the background to the objects position when parenting an object to an animated layer.

Then simply parent the position of the other end of the beam effect to the position of Epicycle (given that the Epicycle has its Anchor Point centered).

Here is an After Effects example project to understand it more easily.

• Hey, I really appreciate the detailed reply, thank you very much. I'll try this tonight and let you know! – Paul Lupascu May 14 '14 at 10:30
• Just ask if you have further questions. – timonsku May 14 '14 at 19:59
• Hello Proffesor FartSparkle! Thanks again for your reply, I used your instructions and you can indeed get a shape to rotate on a circle which is rotating on a circle this way. However, as I see now, there's no way to describe such a path for a shape while using a single position parameter (or how it's called). Our shape will rotate on the circle, and the circle will rotate on another circle, so it's total movement is described by two different layers. If you want to add a beam between the center of the epicycle and Venus, the starting or ending point will only follow one of the two movements. – Paul Lupascu May 18 '14 at 21:01
• You can see this illustrated here – Paul Lupascu May 18 '14 at 21:05
• If you look at the movement of the beams end on the left (the "crosshair" not the visual end of the beam) you see that its going along the epicycle shape but with an offset. I would try to just offset the keyframe animation until it matches the actual position of the epicycle. – timonsku May 18 '14 at 22:42