Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Ione Mabe on May 17, 2023 at 11:05 pm

    Hi, guys!
    I have a simple question. I want to animate a wheel spinning on a animated path.
    Is there a way to get the path length to use in expressions?
    Thanks!

    Ione Mabe replied 3 weeks ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    May 17, 2023 at 11:42 pm

    If you know the diameter (or can get it sourceRectAtTime()) it’s just

    diameter*Math.PI

    If it’s a path, you can approximate the length by using pointOnPath() to chop the path into a bunch of tiny pieces and summing their lengths together, like this:

    path = content("Circle").content("Path 1").path;
    numPts = 100;
    accum = 0;
    for (i = 0; i <= numPts; i++){
    if (i == 0){
    p1 = path.pointOnPath(0);
    }else{
    p0 = p1;
    p1 = path.pointOnPath(i/numPts);
    accum += length(p0,p1);
    }
    }
    accum
  • Ione Mabe

    May 18, 2023 at 12:54 am

    Thank you, Dan!!!
    Chopping the path is precise enough to do the job!

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