POV-Ray : Newsgroups : povray.advanced-users : Random, Displaying values, and a parsing logistics question: Server Time
1 Nov 2024 17:21:32 EDT (-0400)
  Random, Displaying values, and a parsing logistics question: (Message 1 to 5 of 5)  
From: Eitan Tal
Subject: Random, Displaying values, and a parsing logistics question:
Date: 2 May 2001 15:04:26
Message: <3AF0680F.102B9B08@netvision.net.il>
1. How do I use a random value? I remember that a sample had shown that.

2. is it possible to display a value to debug? #debug doesn't do that,
nor #warning.
3. if I use a random texture for a single object:

#declare myObject = box {<0,0,0> <1,1,1> pigment {color rgb <random,
random, random>}}

and do:

object {myObject}
object {myObject translate <1,0,0>}

will they have different colors?


Post a reply to this message

From: Ron Parker
Subject: Re: Random, Displaying values, and a parsing logistics question:
Date: 2 May 2001 15:18:24
Message: <slrn9f0nbb.d8q.ron.parker@fwi.com>
On Wed, 02 May 2001 22:03:27 +0200, Eitan Tal wrote:
>1. How do I use a random value? I remember that a sample had shown that.
>

First, declare a seed:

#declare S=seed(124526); // use some other value for different sequences
                         // of random numbers.

Then use it with the rand function:

#declare R=rand(S) sets R to a random number between 0 and 1 (including 0
but not including 1.)  More info can be found in the "float functions" topic
in the Fine Manual.

>2. is it possible to display a value to debug? #debug doesn't do that,
>nor #warning.

#debug wants string arguments.  Look at the "string functions" topic in 
the Fine Manual.  You want the "str" function.

>3. if I use a random texture for a single object:
>
>#declare myObject = box {<0,0,0> <1,1,1> pigment {color rgb <random,
>random, random>}}
>
>and do:
>
>object {myObject}
>object {myObject translate <1,0,0>}
>
>will they have different colors?

No.  Declaring an object actually creates that object in memory,  It doesn't
reparse the object declaration every time you use it like C's #define does.
To do that, you need #macro:

#macro myObject()
  box {0 1 pigment {color rgb <rand(S), rand(S), rand(S)>}}
#end

object {myObject()}
object {myObject() translate x}



-- 
#local R=<7084844682857967,32787982,826975826580>#macro L(P)concat(#while(P)chr(
mod(P,100)),#local P=P/100;#end"")#end background{rgb 1}text{ttf L(R.x)L(R.y)0,0
translate<-.8,0,-1>}text{ttf L(R.x)L(R.z)0,0translate<-1.6,-.75,-1>}sphere{z/9e3
4/26/2001finish{reflection 1}}//ron.parker@povray.org My opinions, nobody else's


Post a reply to this message

From: Bob H 
Subject: Re: Random, Displaying values, and a parsing logistics question:
Date: 2 May 2001 15:38:42
Message: <3af06242$1@news.povray.org>
"Eitan Tal" <eit### [at] netvisionnetil> wrote in message
news:3AF0680F.102B9B08@netvision.net.il...
> 1. How do I use a random value? I remember that a sample had shown that.

#declare S=seed(123) // any aritrary number
#declare R=rand(S) // the random number put into R

> 2. is it possible to display a value to debug? #debug doesn't do that,
> nor #warning.

You can send a float or string to the message stream by:

#declare MessageNumber=R;
#debug concat("Random number is ", str(MessageNumber,3,1),"\n")

> 3. if I use a random texture for a single object:
>
> #declare myObject = box {<0,0,0> <1,1,1> pigment {color rgb <random,
> random, random>}}
>
> and do:
>
> object {myObject}
> object {myObject translate <1,0,0>}
>
> will they have different colors?

No.  Were it a pigment pattern instead and you moved it before adding
texture it would potentially change.  You're asking if the colors randomize
later though and no it does not (should not).

Bob H.


Post a reply to this message

From: Warp
Subject: Re: Random, Displaying values, and a parsing logistics question:
Date: 3 May 2001 06:12:35
Message: <3af12f13@news.povray.org>
Ron Parker <ron### [at] povrayorg> wrote:
: #debug wants string arguments.

  I still think #debug (and other streams) should be more user-friendly,
as printing functions in other scripting languages, so that you could
write something like:

#declare F1 = 5;
#declare F2 = 3.86;
#declare V = <1,2.8,-3>;
#declare S = "Hello!"

#debug "Some values: ", F1, "; ", F2, "; ", V, "; ", S, "\n"


  This would print:

5; 3.86; <1,2.8,-3>; Hello!

  With the current implementation you have to do this:

#debug concat("Some values: ", str(F1,0,0), "; ", str(F2,0,2), "; <",
              str(V.x,0,0), ",", str(V.y,0,1), ",", str(V.z,0,0), ">; ",
              S, "\n")

-- 
#local D=array[6]{11117333955,7382340,3358,3900569407,970,4254934330}
#local I=0;#macro M()<mod(D[I],13)-6,mod(div(D[I],13),8)-3,10>#end
blob{#while(I<6)cylinder{M()#local D[I]=div(D[I],104);M().5,2
pigment{rgb M()}}#local I=(D[I]>99?I:I+1);#end}               /*- Warp -*/


Post a reply to this message

From: Chris Huff
Subject: Re: Random, Displaying values, and a parsing logistics question:
Date: 3 May 2001 06:22:11
Message: <chrishuff-6B45AB.05194603052001@news.povray.org>
In article <3af12f13@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

>   I still think #debug (and other streams) should be more user-friendly,
> as printing functions in other scripting languages, so that you could
> write something like:

Just allowing them to take the same input you can feed to files would be 
nice...

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

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