Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Get 3D position given the 3D angle and distance

  • Get 3D position given the 3D angle and distance

    Posted by Noel Powell on September 2, 2023 at 6:37 pm

    I’m looking to position some layers in a sphere formation. I realize I could do this by parenting each layer to a separate Null Object, and then rotating the Nulls to make the layers orbit around to different positions on the sphere. But for the project I’m making, I would really prefer to do this with an expression if possible.

    This expression (from Dan Ebberts, I believe) works well to position a layer in a 2D circle around a center point, when given a Distance and Angle value:

    a = effect(“Angle Control”)(“Angle”);

    d = effect(“Slider Control”)(“Slider”);

    r = degreesToRadians(a-90);

    x = d*Math.cos(r);

    y = d*Math.sin(r);

    value + [x,y]

    So I’ve been trying to make a 3D version of this. Ideally, using a 3D Point Control to control the angle. Sorry, I’m not lazy, I’m just too dumb to figure this out. Thank you for your help.

    Brie Clayton replied 9 months, 3 weeks ago 3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    September 2, 2023 at 7:16 pm

    I think I’d set it up with a slider for radius and angle controls for altitude and azimuth, like this:

    r = effect("Radius")("Slider");
    a = effect("Altitude")("Angle");
    az = effect("Azimuth")("Angle");
    center = [thisComp.width/2,thisComp.height/2,0];
    aRad = degreesToRadians(a);
    azRad = degreesToRadians(az);
    y = r*Math.sin(aRad);
    rXZ = r*Math.cos(aRad);
    x = rXZ*Math.cos(azRad);
    z = rXZ*Math.sin(azRad);
    center + [x,y,z]

  • Noel Powell

    September 3, 2023 at 12:30 am

    That works so perfectly, I can’t thank you enough, Dan! Your expression skills are legendary, and I’m so grateful.

  • Brie Clayton

    September 3, 2023 at 1:08 am

    Thank you for your solve, Dan!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy