|
|
"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
|
|