POV-Ray : Newsgroups : povray.newusers : the interpolate bug vs m. newbie : 1-1 Server Time
1 Nov 2024 06:19:02 EDT (-0400)
  the interpolate bug vs m. newbie : 1-1 (Message 1 to 2 of 2)  
From: marc
Subject: the interpolate bug vs m. newbie : 1-1
Date: 5 Apr 2010 15:30:00
Message: <web.4bba39031ec55ee9a97f52b60@news.povray.org>
hi
newbie here
in interpolation confusion

>>> reading 1st :

- doc : 3.2.2.8.4  "Returning a Value Like a Function"
        Interpolate(T,T1,T2,P1,P2) (P1+(T1+T/(T2-T1))*(P2-P1))    5 args
        scenes/language/macros/macro3.pov
        author: Chris Young

        happy to cut & paste Chris Young work,
        i include some std.inc ...

        ------------------------------
        oops : macro need now 6 args !
        ------------------------------


>>> further readings ...

- doc : 3.7.9.1  math.inc "Float functions and macros"
        #macro Interpolate(GC, GS, GE, TS, TE, Method)            6 args
        "Interpolation macro"
        author: Margus Ramst


        -- ok, i have to put includes 1st  to avoid macro overwrite --

        but my_source.pov is
                many lines ...
                tests ...
                then if (animation)
                        include my_include (calling math.inc)
                        interpolate ...
                        then goto_sleep
                else the_end

        maybe some renaming ?

P.S.: thx to the pov team for this marvellous game !
P.S.P.S. : -- ok, after povray language i have to learn more english :)


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: the interpolate bug vs m. newbie : 1-1
Date: 5 Apr 2010 20:55:00
Message: <web.4bba86251fc9903d6291f840@news.povray.org>
"marc" <tra### [at] freefr> wrote:
> hi
> newbie here
> in interpolation confusion
>
> >>> reading 1st :
>
> - doc : 3.2.2.8.4  "Returning a Value Like a Function"
>         Interpolate(T,T1,T2,P1,P2) (P1+(T1+T/(T2-T1))*(P2-P1))    5 args
>         scenes/language/macros/macro3.pov
>         author: Chris Young

The macro you refer to here looks wrong.

  #macro Interpolate(T,T1,T2,P1,P2)
     (P1+(T1+T/(T2-T1))*(P2-P1))
  #end


It should probably have been made like this:


  #macro LinearInterpolate(T, T1, T2, P1, P2)

     (P1 + (T - T1)/(T2 - T1)*(P2 - P1))

  #end // macro LinearInterpolate


Here is how I arrived at that formula:

  (P - P1)/(T - T1) = (P2 - P1)/(T2 - T1)
  P - P1 = (T - T1)*(P2 - P1)/(T2 - T1)
  P = P1 + (T - T1)*(P2 - P1)/(T2 - T1)
  P = P1 + (T - T1)/(T2 - T1)*(P2 - P1)

--
Tor Olav
http://subcube.com


Post a reply to this message

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