POV-Ray : Newsgroups : povray.general : Explain this! Server Time
15 Nov 2024 01:16:06 EST (-0500)
  Explain this! (Message 1 to 5 of 5)  
From: Margus Ramst
Subject: Explain this!
Date: 25 Apr 1999 12:55:48
Message: <37233b04.0@news.povray.org>
I wonder if somebody can explain the following behaviour:

//Return 0 if not parallel, 1 if parallel, -1 if anti-parallel
#macro t_parallel(V1i,V2i)
    #local V1=vnormalize(V1i);
    #local V2=vnormalize(V2i);
    #local Vt=vlength(V1+V2)-1;
    #if(abs(Vt)=1) Vt
    #else 0
    #end
#end

//this works:
#debug concat("Parallel is ",str(t_parallel(y,x),0,3),"\n")

//this returns an error:
#if(t_parallel(y,x)=1|t_parallel(y,x)=-1)
#debug "Parallel or anti-parallel\n"
#else
#debug "Not parallel\n"
#end

//this works:
#if(abs(t_parallel(y,x))=1)
#debug "Parallel or anti-parallel\n"
#else
#debug "Not parallel\n"
#end

//this also works, but _only_ when there is no semi-colon after the float
declaration

#declare A=t_parallel(y,x) //no semi-colon!
#if(A=1|A=-1)
#debug "Parallel or anti-parallel\n"
#else
#debug "Not parallel\n"
#end


Post a reply to this message

From: Lewis
Subject: Re: Explain this!
Date: 25 Apr 1999 17:37:13
Message: <37237CDC.3FA57165@netvision.net.il>
I'm in the proccess of making a site for POV-fest 99, to you guys out
there just relax for the mean time...


Post a reply to this message

From: Lewis
Subject: Argh!!!!!
Date: 25 Apr 1999 17:45:47
Message: <37237EE9.5BD64986@netvision.net.il>
I keep posting messages to the wrong thread....
This message should go under the "Festival of POV" thread below.

ARGH!!!!!!!!!!!!!!!


Post a reply to this message

From: Margus Ramst
Subject: Re: Explain this!
Date: 25 Apr 1999 22:15:15
Message: <3723be23.0@news.povray.org>
I received a solution - the macro call has to be enclosed in parantheneses.
It seems this is necessary when the output data is within a conditional
block, e.g.

#macro A(B) #if(B=B) (B) #end #end

Another way to solve the problem is to add parantheneses in the macro:

#macro A(B) (#if(B=B) (B) #end) #end

Still, I would like to know the reason for this behaviour.

Margus


Post a reply to this message

From: Stephen Lavedas
Subject: Re: Explain this!
Date: 26 Apr 1999 01:25:56
Message: <3723EAEE.B129EECB@virginia.edu>
btw, you only seem to put semi-colons after declares that aren't structs
of some kind.  I've run into errors putting semicolons after #declares
of vectors for instance.  It just seems to be the way the language
works.  A rather interesting erm... "feature" if you ask me.

Steve


Margus Ramst wrote:
> 
> I wonder if somebody can explain the following behaviour:
> 
> //Return 0 if not parallel, 1 if parallel, -1 if anti-parallel
> #macro t_parallel(V1i,V2i)
>     #local V1=vnormalize(V1i);
>     #local V2=vnormalize(V2i);
>     #local Vt=vlength(V1+V2)-1;
>     #if(abs(Vt)=1) Vt
>     #else 0
>     #end
> #end
> 
> //this works:
> #debug concat("Parallel is ",str(t_parallel(y,x),0,3),"\n")
> 
> //this returns an error:
> #if(t_parallel(y,x)=1|t_parallel(y,x)=-1)
> #debug "Parallel or anti-parallel\n"
> #else
> #debug "Not parallel\n"
> #end
> 
> //this works:
> #if(abs(t_parallel(y,x))=1)
> #debug "Parallel or anti-parallel\n"
> #else
> #debug "Not parallel\n"
> #end
> 
> //this also works, but _only_ when there is no semi-colon after the float
> declaration
> 
> #declare A=t_parallel(y,x) //no semi-colon!
> #if(A=1|A=-1)
> #debug "Parallel or anti-parallel\n"
> #else
> #debug "Not parallel\n"
> #end


Post a reply to this message

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