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:03:12 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

Dan Ebberts
Re: Value out of a "while loop" decreases when it should not.
on Dec 1, 2011 at 5:08:43 pm

I think you need to put your p0 and p1 definitions inside the loop (and use j instead of time).

Dan



Return to posts index

Alberto Brancolini
Re: Value out of a "while loop" decreases when it should not.
on Dec 1, 2011 at 6:27:37 pm

Thank you very much.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]