POV-Ray : Newsgroups : povray.general : I need math help : Re: I need math help Server Time
6 Aug 2024 14:22:47 EDT (-0400)
  Re: I need math help  
From: Tor Olav Kristensen
Date: 5 Mar 2002 18:45:42
Message: <3C855736.7D202442@hotmail.com>
=Bob= wrote:
> 
> I need a formula to slowly adjust one value to
> another value over a known period. For example,
> I have an increment value of 1 and I want that
> value to decrease until it's 0 (or some other
> value as needed, 0 for now). And I must reach
> the known period (length in this case).
> 
> So I would be doing something like:
> 
> somelen = 62;
> incval = 1;
> someotherval = ?
> 
> for (x=0;x<somelen;x+=incval)
>     {
>     incval -= someotherval;
>     if (incval <= 0)
>         break;
>     }
> 
> I need x to achieve "somelen" and "incval" to
> achieve the value of 0 at about the same time,
> give or take a bit.
> 
> How do I calculate "someotherval" ?
> Thanks for your help.

Since you're asking in povray.general,
I'll answer with a POV script:

#declare StartValue = 31;
#declare EndValue = 3;
#declare NrOfSteps = 10;

#declare dValue = (EndValue - StartValue)/NrOfSteps;
#declare Step = 0;
#while (Step <= NrOfSteps)
  #declare X = StartValue + Step*dValue;
  #debug "\n"
  #debug str(X, 0, -1)
  #declare Step = Step + 1;
#end // while
#debug "\n"


Tor Olav


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.