ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Z space position offset in only negative direction with radial fall off

FAQ   •   VIEW ALL
 Z space position offset in only negative direction with radial fall off on Feb 19, 2019 at 8:00:43 pm

Expressions Gurus,
Kindly help me out;
I need you to point to how i can assemble an expression that can do this:
Imagine a composition with many small 3D squares making up a grid facing the camera. I would want them to be offset radially from the z=0 through -(negative direction only ) such that those in the middle are offset /closer to the camera from their z=0 position and those on the sides a little closer to ther z= 0.

Below is an illustration as seen from the top AE view

Layers-> - -
- -
- -
- -
--

.camera.-> ₩

It would be super awesome if the expression also arranged the layers in a gridlike arrangement on the xy axis.
Any help is more than appreciated. I do know basic to medium level expressions but want to go deeper into the abyss so bring the big guns if needed.

Rockie Ssengonzi
for
UGANDANE
Simply With Finess & Flair

 Re: Z space position offset in only negative direction with radial fall offon Feb 19, 2019 at 8:40:36 pm

This might get you headed in the right direction:

``` maxDisplacement = 100; maxRadius = 500; C = thisComp.layer("Camera 1"); v1 = C.toWorldVec([0,0,1]); v2 = toWorld(anchorPoint) - C.toWorld([0,0,0]); a = Math.acos(clamp(dot(normalize(v2),v1),-1,1)); d = length(v2)*Math.sin(a); zDisp = easeOut(d,0,maxRadius,maxDisplacement,0); value - [0,0,zDisp] ```

Dan