Chrisir <nomail@nomail> wrote:
> How can I make positively sure that my spline starts exactly
> always and definetly in P1 and ends exactly
> always and definetly in P2?
> #declare ctr = 0;
> #while (ctr < 1)
...
> #declare ctr = ctr + 0.01;
> #end // end of while
Basic programming "trick":
You shouldn't use such a floating point number directly as your loop
counter. 0.01 cannot be represented accurately in binary floating point
and thus the sum you are accumulating in 'ctr' will become more and more
inaccurate, and there's a high chance that the loop will not be executed
the exact amount of times you want.
Instead, you should do it like this:
#declare Index = 0;
#while(Index < 100)
#declare ctr = Index/99;
... (the loop body, which uses 'ctr') ...
#declare Index = Index+1;
#end
This makes sure that the loop will be executed exactly 10 times and
that 'ctr' will get values between exactly 0 and 1.
--
- Warp
Post a reply to this message
|