POV-Ray : Newsgroups : povray.general : Math r dumb-Ken r toopid Server Time
12 Aug 2024 13:15:29 EDT (-0400)
  Math r dumb-Ken r toopid (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: Ken
Subject: Math r dumb-Ken r toopid
Date: 19 Feb 1999 13:28:37
Message: <36CDACF0.398D5F39@pacbell.net>
Howdy Ya'll !

 Is it possible to trap a specific number generated by the rand
function to be used in another portion of a loop ?

  An example of why I ask would be to create non umiform scaled wood
shingles for a roof. They are usually the same in thichkess and length
but the width varies. I could use the rand function within a loop to
vary the scale of each oject generated but it would greatly complicate
the position of the shingles as they are translated into postion through
the loop count. My idea of a solution would be know what variation of
scaling is given by the rand function for each object and using that
value to adjust the translated position of the objects accordingly.
 Is it possible to do something like this and if so how, what, when,
where, and why ?

I appreciate your thoughtful consideration in this matter.

-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: Jerry Anning
Subject: Re: Math r dumb-Ken r toopid
Date: 19 Feb 1999 14:50:15
Message: <36cdbe96.16933852@news.povray.org>
On Fri, 19 Feb 1999 10:26:56 -0800, Ken <tyl### [at] pacbellnet> wrote:


> Is it possible to trap a specific number generated by the rand
>function to be used in another portion of a loop ?
>
>  An example of why I ask would be to create non umiform scaled wood
>shingles for a roof. They are usually the same in thichkess and length
>but the width varies. I could use the rand function within a loop to
>vary the scale of each oject generated but it would greatly complicate
>the position of the shingles as they are translated into postion through
>the loop count. My idea of a solution would be know what variation of
>scaling is given by the rand function for each object and using that
>value to adjust the translated position of the objects accordingly.
> Is it possible to do something like this and if so how, what, when,
>where, and why ?

Just generate the random number separately, save it in a variable, and
use it in both places.  For your shingling project, in order to
account for the variable positions of other shingles, you could either
save the random numbers in an array as you create them and sum the
correct row or column for the needed offset, or (bad idea) reset the
random number stream with the original seed and run the random number
through the needed number of iterations at placement time.  If you are
crazy enough to do that, you will also have to reseed and iterate each
time in the placement loop.  An array would be much better.

Jerry Anning
clem "at" dhol "dot" com


Post a reply to this message

From: PoD
Subject: Re: Math r dumb-Ken r toopid
Date: 19 Feb 1999 15:00:04
Message: <36CDC2C0.649C@merlin.net.au>
Hi Ken,
Not sure I understand your problem.
Do you mean something like

#declare NextX = 0;
#while( NextX < 20 )
  #delare Scale = 1+rand(Seed);
  box{0,1 scale Scale}
  translate <NextX,0,0>
  #declare NextX = NextX + Scale
#end

PoD.


Post a reply to this message

From: Ken
Subject: Re: Math r dumb-Ken r toopid
Date: 19 Feb 1999 18:02:16
Message: <36CDED14.95606CD8@pacbell.net>
Jerry Anning wrote:
> 

> 
> Just generate the random number separately, save it in a variable, and
> use it in both places.  For your shingling project, in order to
> account for the variable positions of other shingles, you could either
> save the random numbers in an array as you create them and sum the
> correct row or column for the needed offset, or (bad idea) reset the
> random number stream with the original seed and run the random number
> through the needed number of iterations at placement time.  If you are
> crazy enough to do that, you will also have to reseed and iterate each
> time in the placement loop.  An array would be much better.
> 
> Jerry Anning
> clem "at" dhol "dot" com

I understand how to use arrays but am unsure hot to pass a value to one
for storage and later retrieval. A brief example would be appreciated.

-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: Ken
Subject: Re: Math r dumb-Ken r toopid
Date: 19 Feb 1999 18:05:25
Message: <36CDEDD1.399182D7@pacbell.net>
PoD wrote:
> 
> Hi Ken,
> Not sure I understand your problem.
> Do you mean something like
> 
> #declare NextX = 0;
> #while( NextX < 20 )
>   #delare Scale = 1+rand(Seed);
>   box{0,1 scale Scale}
>   translate <NextX,0,0>
>   #declare NextX = NextX + Scale
> #end
> 
> PoD.

I thought it might be accomplished in a way similar to this but never
would have thought to increment the counter with the scale value.
I will check it out and see what happens.

 Thank you !

-- 
Ken Tyler

mailto://tylereng@pacbell.net


Post a reply to this message

From: Stephen Lavedas
Subject: Re: Math r dumb-Ken r toopid
Date: 19 Feb 1999 18:37:56
Message: <36CDF5EF.41A3FA1B@virginia.edu>
While I would be in favor of a solution like PoD's, storing and
retrieving from an array is easy.
#declare num = 20;
#declare MyArray = array[Num];
#declare i = 0;
#while (i < num)
   #declare MyArray[i] = i;
   #declare i = i + 1;
#end
this stores the current value of i into the array at each position (so
MyArray[5] = 5) to get them out, simply do something like the following

#declare i = 0;
#declare Sum = 0;
#while (i < num)
   #declare Sum = Sum + MyArray[i];
   #declare i = i + 1;   
#end

it is that simple.

Steve

Ken wrote:
> 
> Jerry Anning wrote:
> >
> 
> >
> > Just generate the random number separately, save it in a variable, and
> > use it in both places.  For your shingling project, in order to
> > account for the variable positions of other shingles, you could either
> > save the random numbers in an array as you create them and sum the
> > correct row or column for the needed offset, or (bad idea) reset the
> > random number stream with the original seed and run the random number
> > through the needed number of iterations at placement time.  If you are
> > crazy enough to do that, you will also have to reseed and iterate each
> > time in the placement loop.  An array would be much better.
> >
> > Jerry Anning
> > clem "at" dhol "dot" com
> 
> I understand how to use arrays but am unsure hot to pass a value to one
> for storage and later retrieval. A brief example would be appreciated.
> 
> --
> Ken Tyler
> 
> mailto://tylereng@pacbell.net


Post a reply to this message

From: Gordon
Subject: Re: Math r dumb-Ken r toopid
Date: 20 Feb 1999 06:33:20
Message: <36ce9d80.0@news.povray.org>
Ken wrote in message <36CDEDD1.399182D7@pacbell.net>...
>PoD wrote:

>> 

>> Hi Ken,

>> Not sure I understand your problem.

>> Do you mean something like

>> 

>> #declare NextX = 0;

>> #while( NextX < 20 )

>>   #delare Scale = 1+rand(Seed);

>>   box{0,1 scale Scale}

>>   translate <NextX,0,0>

>>   #declare NextX = NextX + Scale

>> #end

>> 

>> PoD.

>

>I thought it might be accomplished in a way similar to this but never

>would have thought to increment the counter with the scale value.

>I will check it out and see what happens.

>

> Thank you !

>

>-- 

>Ken Tyler

>

>mailto://tylereng@pacbell.net


It might help if you don't think of NextX as a counter, but as a position. We get used
to using #while because there is no #for, but it is a more general loop than that.

Gordon
<gbe### [at] birdcameroncomau>


Post a reply to this message

From: Ron Parker
Subject: Re: Math r dumb-Ken r toopid
Date: 22 Feb 1999 11:58:53
Message: <36d18ccd.0@news.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3aGlsZSBiZWNhdXNlIHRo
>ZXJlIGlzIG5vICNmb3IsIGJ1dCBpdCBpcyBhIG1vcmUgZ2VuZXJhbCBsb29wIHRoYW4gdGhhdC4N
>Cg0KR29yZG9uDQo8Z2JlbnRsZXlAYmlyZGNhbWVyb24uY29tLmF1Pg0KDQo=

Now I've officially seen everything:

Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: base64

What kind of stupid newsreader would even think about letting someone do 
this? Oh, I see.  It's another fine Microsoft product.


Post a reply to this message

From: Rudy Velthuis
Subject: Re: Math r dumb-Ken r toopid
Date: 22 Feb 1999 15:09:00
Message: <36d1b95c.0@news.povray.org>
Ron Parker schrieb in Nachricht <36d18ccd.0@news.povray.org>...
>On Sat, 20 Feb 1999 19:33:24 +0800, Gordon <gbe### [at] birdcameroncomau>
wrote:
>>DQpLZW4gd3JvdGUgaW4gbWVzc2FnZSA8MzZDREVERDEuMzk5MTgyRDdAcGFjYmVsbC5uZXQ+Li
4u

[snip]

>>Cg0KR29yZG9uDQo8Z2JlbnRsZXlAYmlyZGNhbWVyb24uY29tLmF1Pg0KDQo=
>
>Now I've officially seen everything:
>
>Content-Type: text/plain; charset="iso-8859-1"
>Content-Transfer-Encoding: base64
>
>What kind of stupid newsreader would even think about letting someone do
>this? Oh, I see.  It's another fine Microsoft product.

Whoops, I didn't see what you meant (for the POV stuff, I normally use M$OE,
because of the pretty picture shows), but when I saved Gordon's post and
loaded it with a text editor, I could see. Really looks a bit illegible,
doesn't it?

The original said:

------------------------------->8----cut
here---------------------------------------
<QUOTE>
Ken wrote in message <36CDEDD1.399182D7@pacbell.net>...
>PoD wrote:
>>
>> Hi Ken,
>> Not sure I understand your problem.
>> Do you mean something like
>>
>> #declare NextX = 0;
>> #while( NextX < 20 )
>>   #delare Scale = 1+rand(Seed);
>>   box{0,1 scale Scale}
>>   translate <NextX,0,0>
>>   #declare NextX = NextX + Scale
>> #end
>>
>> PoD.
>
>I thought it might be accomplished in a way similar to this but never
>would have thought to increment the counter with the scale value.
>I will check it out and see what happens.
>
> Thank you !
>
>--
>Ken Tyler
>
>mailto://tylereng@pacbell.net

It might help if you don't think of NextX as a counter, but as a position.
We get used to using #while because there is no #for, but it is a more
general loop than that.

Gordon
<gbe### [at] birdcameroncomau>
</QUOTE>
-----------------------------------------------cut
here------------------8<---------------

--
Rudy Velthuis


Post a reply to this message

From: PoD
Subject: Re: Math r dumb-Ken r toopid
Date: 22 Feb 1999 15:41:57
Message: <36D1C115.3B59@merlin.net.au>
Rudy Velthuis wrote:
[ snip snip ]
> 
> It might help if you don't think of NextX as a counter, but as a position.
> We get used to using #while because there is no #for, but it is a more
> general loop than that.
> 
> Gordon
> <gbe### [at] birdcameroncomau>
> </QUOTE>
> -----------------------------------------------cut
> here------------------8<---------------
> 
> --
> Rudy Velthuis

Yeah, that's why I called it NextX. In my mind at least that's kind of a
hint that it's the x offset of the next object rather than just a
counter.

Cheers, PoD.


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

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