ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Distribute evenly in a circle

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jessica Lawheed
Distribute evenly in a circle
on Mar 6, 2020 at 7:24:45 pm

Hi there,

Currently I have a layer set with Motionv2 Orbit. The expression in the "calibrate" or "offset" control is this: clamp(value, -359, 359);

What can I add to this expression so that any time I duplicate the layer, it will space all of the layers out evenly around the circle according to how many layers there are?

clamp(value, -359, 359);


Return to posts index

Andrei Popa
Re: Distribute evenly in a circle
on Mar 7, 2020 at 8:30:44 am

I don't know about Motion2 Orbit, but for what you need i suggest this approach.

On your layer(the one that orbitates on the circle) add a slider named Radius. This is the radius of the circle. Then add this to anchorpoint:

var left = sourceRectAtTime(time,false).left;
var myHeight = sourceRectAtTime(time,false).height;
var myWidth = sourceRectAtTime(time,false).width;
var top = sourceRectAtTime(time,false).top;
[left+myWidth/2-effect("Radius")("Slider"),myHeight/2+top]


Then add this to rotation.

360/thisComp.numLayers*index

This works in a comp where only the initial layer and its copies exist. But you can alter the code from the rotation a bit to fit any case.

For example, you can replace thisComp.numLayers with the number of your copies.
Or instead of index, you can writen index-n, where n equals the index of the first layer -1.

Andrei
My Envato portfolio.


Return to posts index

Jessica Lawheed
Re: Distribute evenly in a circle
on Mar 9, 2020 at 3:40:33 pm

Thank you for this reply. I will be able to use this method for a few other things in other projects but sadly not for the one referenced in this thread. They don't have the ability to then orbit the center of the circle they've made, or adjust according to the radius if I change it. If it helps, the code embedded in the position of this layer is as such:

calibrate = effect("Position - Orbit Calibrate")("ADBE Slider Control-0001") / 57;
on_off = effect("Position - Orbit Direction")("ADBE Checkbox Control-0001");
d = effect("Position - Orbit Distance")("ADBE Slider Control-0001") * 15;
s = effect("Position - Orbit Speed")("ADBE Slider Control-0001") / 10;

try {
L = effect("Position - Orbit Target")("ADBE Layer Control-0001");
center = L.toWorld(L.anchorPoint);
} catch (err) {
center = value;
}
myTime = Math.max(0, time - inPoint);
if (on_off == 1) {
angle = (s * myTime * 2 * Math.PI) + calibrate;
} else {
angle = ((s * myTime * 2 * Math.PI) + calibrate) * -1;
}
value = center + [Math.sin(angle) / thisComp.pixelAspect, -Math.cos(angle)] * d;


Return to posts index


Andrei Popa
Re: Distribute evenly in a circle
on Mar 10, 2020 at 8:35:02 am

To make them orbit or change radius, you just have to centralize the data. I added a null as the last layer in that comp and 2 sliders to it: Radius and Rotiation. Modify these 2 in order to change the radius/make the objects orbit. Here are the new expressions added to anchor point and rotation of the layers.

Anchor Point:

var left = sourceRectAtTime(time,false).left;
var myHeight = sourceRectAtTime(time,false).height;
var myWidth = sourceRectAtTime(time,false).width;
var top = sourceRectAtTime(time,false).top;
[left+myWidth/2-thisComp.layer("Center").effect("Radius")("Slider"),myHeight/2+top]


Rotation:
360/(thisComp.numLayers-1)*index+thisComp.layer("Center").effect("Rotation")("Slider")

Also, here is a link to my project in case you want to check it out. https://www.dropbox.com/s/n4dsozkm5imxein/Circle%20payers.aep?dl=0

Andrei
My Envato portfolio.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]