FORUMS: list search recent posts

Value out of a "while loop" decreases when it should not.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Alberto Brancolini
Value out of a "while loop" decreases when it should not.
on Dec 1, 2011 at 5:01:36 pm

Hallo everyone.

Here I've got a weird behavior -to me, at least- by an expression and I'd like to understand where's the mistake I made.

I wanted to have an esteem of the overall distance of a cycling course.
After drawing a mask all along the roads, I pasted it to a null's position and turned the comp's framerate to 50 for a higher accuracy.
Then I took Dan Ebbert's (thank you, your website saves my life almost daily) expression for accumulating random values and I fitted it to my need. At the end, I divided for the maps scale.

Now the fun part: the value sometimes decreases, expecially when the path bends.

My knowledge is that a curve may not be represented correctly, but it's still a vector between two points.

So, can you tell me where's my mistake?

Thank you.

j = 0; //counter
dist = 0; //distance
p1 = transform.position.valueAtTime(time);
p0 = transform.position.valueAtTime(time-thisComp.frameDuration);

while (j<time) {
dist += length(p1-p0);
j += thisComp.frameDuration;
dist/comp("scala").layer("Null 4").effect("fattoreConv")("Slider")/10;

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved