Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions sine/cosine interpolation hand-written

  • sine/cosine interpolation hand-written

    Posted by Micheel Leavitt on February 27, 2010 at 1:24 am

    Hello, I started my first trig class, and I was playing around with ideas to put a variety of points that are arranged in space and connect them with Write-on using cosine interpolation. I got the first two points to connect pretty easily:

    p1 =thisComp.layer(“P1”).transform.position;
    p2 = thisComp.layer(“P2”).transform.position;
    t = -Math.cos(Math.PI*time)/2 + .5;
    linX = p1[0] + t*(p2[0]-p1[0]);
    linY = p1[1] + time*(p2[1]-p1[1]);
    [linX,linY]

    but I want to loop p1 and p2 so when the line goes from p1 to p2, the expression will update and make p1 into p2 and p2 into p3 (the dots are named this in the comp to make things simple) I am figuring it is done with a while loop or maybe a long if/else function but I’m not altogether sure how to set it up. Thanks for any help!

    Elad Menashe replied 16 years, 2 months ago 2 Members · 1 Reply
  • 1 Reply
  • Elad Menashe

    March 4, 2010 at 3:01 pm

    I’m not sure I understand you correctly, there are to options, let me know what fits best your desire:
    1) go from p1 to p2 in a ping-pong loop
    2) go from p1 to p2 when reaching p2 go to p3, when reaching p(i) go to p(i+1)

    if option 1 is the one: linY should be:
    linY = p1[1] + t*(p2[1]-p1[1]);

    if option 2 is the one you have several options
    a. hardcode it, set times: t2, t3. when time < t2 interpolate from p1 to t2, etc. b. use comp markers to define when to interpolate, this is also involve hardcoding the points, but you will be able to play with the times more easily. Let me know if that helps Elad

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