POV-Ray : Newsgroups : povray.advanced-users : Macros acting strange : Macros acting strange Server Time
30 Jul 2024 04:24:02 EDT (-0400)
  Macros acting strange  
From: Sigmund Kyrre Aas
Date: 28 Mar 2000 14:43:02
Message: <38E10B3A.7C6D3308@stud.ntnu.no>
This code shows something I found the other day: a macro (intp) wich returns a
number, affects the x-value when used in some vector expressions.

At first I thought it was a bug in MegaPov, but it also shows up in 
POV-Ray 3.1e

#macro intp(X,X1,Y1,X2,Y2)
    (Y2-Y1)/(X2-X1)*X - (Y2-Y1)/(X2-X1)*X1 + Y1
#end

#macro Print(V1)
    #local v1=V1*<1,1,1>;
    #render concat(
        str(i,1,0),": <",
        str(v1.x,2,1),", ",
        str(v1.y,2,1),", ",
        str(v1.z,2,1),">\n"
    )
#end

#declare var1=.1;
#declare var2=1;

// this one adds var1*x
#declare i=0;
#while (i<=3) 
    Print( x + (y+z)*intp(i, 0, var1, 3, var2)  )
    #local i=i+1; 
#end 
#render "\n"

// this is fine
#declare i=0;
#while (i<=3) 
    Print( <1, intp(i, 0, var1, 3, var2), intp(i, 0, var1, 3, var2)>  )
    #local i=i+1; 
#end 
#render "\n"

//this is fine
#declare i=0;
#while (i<=3) 
    Print( x + (y+z)*.3*i  )
    #local i=i+1; 
#end 
#render "\n"

//this is also fine
#declare i=0;
#while (i<=3) 
    Print( <1, .3*i, .3*i>  )
    #local i=i+1; 
#end


Post a reply to this message

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