POV-Ray : Newsgroups : povray.general : Strange behavior : Re: Strange behavior Server Time
22 Jun 2024 23:35:31 EDT (-0400)
  Re: Strange behavior  
From: Anthony D  Baye
Date: 16 Jan 2015 23:20:01
Message: <web.54b9e246ec0f5b60bd92286f0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 17.01.2015 um 02:05 schrieb eticre:
>
> > this fail
> >
> > #declare rndx=seed(123);
> > #macro rnr(nrx,mii,mxx)
> >   #if(mii>=0)
> >     (rand(nrx)*(mxx-mii+1)) + mii
> >   #else
> >     mii+(mxx-mii)*rand(nrx) /////////  LINE 40
> >   #end
> > #end
> >
> > #local d=0;
> > #local d=rnr(rndx,-20,20);
>
> This is a known issue rooted deep in the current parser (and not due to
> be fixed before implementation of a brand new parser); to work around,
> first assign the expression to a local variable, then finally "return" that:
>
>    #macro rnr(nrx,mii,mxx)
>      #if(mii>=0)
>        #local result = (rand(nrx)*(mxx-mii+1)) + mii;
>      #else
>        #local result = mii+(mxx-mii)*rand(nrx);
>      #end
>      result
>    #end
>
> The issue reported by the OP, however, is that this construct allegedly
> doesn't always seem to work either; but for the time being I presume
> that Anthony accidently did something wrong.

I could have been certain that I did exactly this, but I suppose that
considering the complexity of what I was working on, there was something I
missed.

my simple test, also works for both cases:

#version 3.7;

light_source { <5, 10, -30> rgb 1 }
camera {
  perspective
  location <0.0, 0.0, -10.0>
  up y
  right x*(image_width/image_height)
  look_at 0
  }

#macro mrav(V)
  #local result = V;
  // stuff and junk...
  result
#end

#declare myval = mrav(5);

sphere { 0.0 0.125 pigment { rgb 1 } translate mrav(5)*x }

Regards,
A.D.B.


Post a reply to this message

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