Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions non circular spiral

  • non circular spiral

    Posted by Chifei Soong on May 17, 2012 at 7:20 am

    Hi CCgurus 🙂 how to create a non-circular spiral position (constant speed) using expressions?

    My current clumsy solution is:

    loop the null-A around a predefined path(pasted mask on position) using loopOut. and then parent that object to another shrinking/expanding null-B.

    and finally attach a writeOn/Particular fx to nullA
    ———————–
    is it possible to achieve this in a more elegant way by using expression without for-loop where the shape of spiral could be defined by rotation angle?

    thanks in advance 🙂

    Xavier Gomez replied 12 years, 11 months ago 4 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    May 17, 2012 at 1:12 pm

    I’m not sure what you mean by non-circular spiral. Does something like this work?

    t = Math.max(time-inPoint,0);
    r = 50*t;
    f = 1;
    center = [thisComp.width,thisComp.height]/2;
    a = f*t*Math.PI*2;
    x = Math.cos(angle);
    y = Math.sin(angle);
    center + [x,y]*r;

    Dan

  • Chifei Soong

    May 17, 2012 at 1:48 pm

    thanks Dan,
    below is an expression of a shrinking circular spiral –

    ====================
    what i wanted to achieve is a square (or triangle) kind of spiral movement. which looks like this 🙂
    will best if the shape of the spiral can be controlled by an angle value Or numOfSides
    ===================
    thank you for your time 🙂

    //circular spiral
    c=C.layer.position; //center
    r=linear(time,inPoint,inpoint+3,300,0); //radius
    x=r*Math.sin(time*20);
    y=r*Math.cos(time*20);
    c+[x,y]

  • Jorge Estrada

    May 30, 2013 at 3:00 am

    how can i make it into triangular?

  • Xavier Gomez

    May 30, 2013 at 2:34 pm

    This works for any polygone. It can be simplified though if you need a regular shape, and it is probably easier to animate the “angle” and the “radius” with aditionnal sliders than to use functions (caps are to see them for afar…)

    ///////////////////////////////// TWEAKS ///////////////////////////////////////
    function ANGLE(t){ // returns an angle in degrees...
    return t * 60;}

    function RADIUS(angle){ // angle is in radians ...
    return angle * 10;}

    center = [thisComp.width*0.5, thisComp.height*0.5];
    angleList = [0,30, 120,150, 240,270] // degrees, in increasing order, from 0 (included) to 360 (excluded)

    /////////////////////////////////////////////////////////////////////////////////////

    last = angleList.length-1;

    a=ANGLE(time); // use a function as above, or a slider to animate the angle (same for the radius)
    n=Math.floor(a/360);
    b=a-n*360;

    if (b<=angleList[0]){ // < === "less or equal"
    a1 = (n-1) * 360 +angleList[last]; a2 = n*360+angleList[0];
    }
    else if (angleList[last]<=b){
    a1 = n * 360 + angleList[last]; a2 = (n+1)*360+angleList[0];
    }
    else{
    idx=0;
    while (b>angleList[idx+1]){idx++;};
    a1 = n * 360 + angleList[idx++]; a2 = n*360+angleList[idx];
    }

    a = degreesToRadians(a);
    a1 = degreesToRadians(a1);
    a2 = degreesToRadians(a2);
    P = RADIUS(a1) * [Math.cos(a1), Math.sin(a1)];
    Q = RADIUS(a2) * [Math.cos(a2), Math.sin(a2)];

    center + linear(a, a1, a2, P,Q)
    ;

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