Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Making a light orbit a point in 3D space

  • Making a light orbit a point in 3D space

    Posted by Peter Klavins on December 10, 2011 at 10:52 am

    Hello all,
    I have a comp where I want a light to orbit the very centre (in this case 480,360,0) in a circle of radius r, and the orbit shifts over time (so if the light left a trail of infinite-life particles, a sphere would gradually build up around the centre point). I’ve tried to convert the light’s x,y,z coordinates into spherical polar coordinates, but it didn’t work out and I don’t know enough of AE expressions to get it right. Essentially, in the Position field I put the code below, but it gives an error…

    rho = Math.sqrt(value[0]*value[0] + value[1]*value[1] + value[2]*value[2]);
    phi = Math.atan(value[1]/value[0]);
    theta = Math.acos(rho/phi);
    [rho, phi, theta]

    Peter Klavins replied 14 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    December 10, 2011 at 5:03 pm

    If I were doing this, I would just put two 3D nulls at the center of the comp and make one the parent of the light and the other the parent of the other null. Then just rotate one null on y and the other on x.

    Dan

  • Peter Klavins

    December 10, 2011 at 11:26 pm

    I assume I’d include a third null if I wanted to make it orbit in the z dimension as well?

    Thing is, I’m trying to make this somewhat reacting to audio, so I wanted to vary the distance of the light from the origin (in this case the centre of the comp) based on some keyframes derived from audio. I can see that being much easier to do with a value like r… or is there an easy way I’m not seeing?

    (The code below is what I currently have, and that makes it rotate nicely around the centre.)

    x = Math.sin(time)*200 + 480;
    [x, position[1], position[2]] ***first null***

    y = Math.cos(time)*200+360;
    temp = thisComp.layer("x rotator").transform.position[0];
    [temp, y, position[2]] ***second null***

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