POV-Ray : Newsgroups : povray.general : The Eternal Student: Loop Problem Server Time
22 Dec 2024 13:58:10 EST (-0500)
  The Eternal Student: Loop Problem (Message 1 to 7 of 7)  
From: Sven Littkowski
Subject: The Eternal Student: Loop Problem
Date: 28 Jan 2018 20:24:50
Message: <5a6e77e2$1@news.povray.org>
For some reason, my loop doesn't produce many items as intended, only
one. And I am sure, as usual I am not seeing the forest because of all
the trees in front of my eyes!  :-D


#declare MyRandom = seed (27053);
#local MyLength   = int(20*rand(MyRandom));   // Anzahl der Glieder
#local MyX        = rand(MyRandom)*45;
#local MyY        = rand(MyRandom)*1;
#local MyZ        = rand(MyRandom)*10;
#local MyElement  = 0;

#while (MyElement<MyLength)
 object { Element translate < 0.0, 0.0, 0.45 > rotate < MyX, MyY, MyZ > }
 #local MyX        = rand(MyRandom)*45;
 #local MyY        = rand(MyRandom)*1;
 #local MyZ        = rand(MyRandom)*10;
 #local MyElement  = MyElement+1;
#end


Post a reply to this message

From: Thomas de Groot
Subject: Re: The Eternal Student: Loop Problem
Date: 29 Jan 2018 02:49:07
Message: <5a6ed1f3$1@news.povray.org>
On 29-1-2018 2:24, Sven Littkowski wrote:
> For some reason, my loop doesn't produce many items as intended, only
> one. And I am sure, as usual I am not seeing the forest because of all
> the trees in front of my eyes!  :-D
> 
> 
> #declare MyRandom = seed (27053);
> #local MyLength   = int(20*rand(MyRandom));   // Anzahl der Glieder
> #local MyX        = rand(MyRandom)*45;
> #local MyY        = rand(MyRandom)*1;
> #local MyZ        = rand(MyRandom)*10;
> #local MyElement  = 0;
> 
> #while (MyElement<MyLength)
>   object { Element translate < 0.0, 0.0, 0.45 > rotate < MyX, MyY, MyZ > }
>   #local MyX        = rand(MyRandom)*45;
>   #local MyY        = rand(MyRandom)*1;
>   #local MyZ        = rand(MyRandom)*10;
>   #local MyElement  = MyElement+1;
> #end
> 

All the objects are at the same location :-)

You need to randomise the translate elements too.

-- 
Thomas


Post a reply to this message

From: Sven Littkowski
Subject: Re: The Eternal Student: Loop Problem
Date: 29 Jan 2018 03:27:29
Message: <5a6edaf1$1@news.povray.org>
I am doing that now: I declared an initial position, and inside the loop
move that position forward at a fixed amount. Aim is to create something
like a chain-alike structure. However, I still have the same problem:
only one item is visible. I don't even see any more items in different
angles, not even at the same position.


#declare MyRandom = seed (27053);
#local MyLength   = int(20*rand(MyRandom));   // Anzahl der Glieder
#local MyX        = rand(MyRandom)*45;
#local MyY        = rand(MyRandom)*1;
#local MyZ        = rand(MyRandom)*10;
#local MyPosition = 0.00;
#local MyElement  = 0;

#while (MyElement<MyLength)
 object { Element translate < 0.0, 0.0, MyPosition > rotate < MyX, MyY,
MyZ > }
 #declare MyRandom = seed (27053);
 #local MyX        = rand(MyRandom)*45;
 #local MyY        = rand(MyRandom)*1;
 #local MyZ        = rand(MyRandom)*10;
 #local MyPosition = MyPosition+0.45;
 #local MyElement  = MyElement+1;
#end


Post a reply to this message

From: Sven Littkowski
Subject: Re: The Eternal Student: Loop Problem
Date: 29 Jan 2018 03:38:51
Message: <5a6edd9b@news.povray.org>
Problem solved, thanks a lot! :-D


Post a reply to this message

From: Kontemplator
Subject: Re: The Eternal Student: Loop Problem
Date: 29 Jan 2018 07:05:00
Message: <web.5a6f0cede85d5c0eb414b8600@news.povray.org>
Sven Littkowski <I### [at] SvenLittkowskiname> wrote:
> I am doing that now: I declared an initial position, and inside the loop
> move that position forward at a fixed amount. Aim is to create something
> like a chain-alike structure. However, I still have the same problem:
> only one item is visible. I don't even see any more items in different
> angles, not even at the same position.
>
>
> #declare MyRandom = seed (27053);
> #local MyLength   = int(20*rand(MyRandom));   // Anzahl der Glieder
> #local MyX        = rand(MyRandom)*45;
> #local MyY        = rand(MyRandom)*1;
> #local MyZ        = rand(MyRandom)*10;
> #local MyPosition = 0.00;
> #local MyElement  = 0;
>
> #while (MyElement<MyLength)
>  object { Element translate < 0.0, 0.0, MyPosition > rotate < MyX, MyY,
> MyZ > }
>  #declare MyRandom = seed (27053);
>  #local MyX        = rand(MyRandom)*45;
>  #local MyY        = rand(MyRandom)*1;
>  #local MyZ        = rand(MyRandom)*10;
>  #local MyPosition = MyPosition+0.45;
>  #local MyElement  = MyElement+1;
> #end

Thats a nice trap for the average brain. :)

#warning concat(str(MyLength,1,1)) shows that your initial myLengt is 1. Try
another seed value or change your random to MyLength = Min +
Int(Max*rand(MyRandom));


Post a reply to this message

From: Alain
Subject: Re: The Eternal Student: Loop Problem
Date: 29 Jan 2018 17:58:03
Message: <5a6fa6fb@news.povray.org>
Le 18-01-28 à 20:24, Sven Littkowski a écrit :
> For some reason, my loop doesn't produce many items as intended, only
> one. And I am sure, as usual I am not seeing the forest because of all
> the trees in front of my eyes!  :-D
> 
> 
> #declare MyRandom = seed (27053);
> #local MyLength   = int(20*rand(MyRandom));   // Anzahl der Glieder
> #local MyX        = rand(MyRandom)*45;
> #local MyY        = rand(MyRandom)*1;
> #local MyZ        = rand(MyRandom)*10;
> #local MyElement  = 0;
> 
> #while (MyElement<MyLength)
>   object { Element translate < 0.0, 0.0, 0.45 > rotate < MyX, MyY, MyZ > }
>   #local MyX        = rand(MyRandom)*45;
>   #local MyY        = rand(MyRandom)*1;
>   #local MyZ        = rand(MyRandom)*10;
>   #local MyElement  = MyElement+1;
> #end
> 

If "Element" is at the origin, the rotation don't make it move. So, each 
object are at the same location. If there is no obvious way to 
distinguish one rotated object from another object with a different 
rotation, like several spheres, you'll only see what look like a single 
object.
Your rotates are:
0 to 45° around the X axis.
0 to 1° around the Y axis = negligeable.
0 to 10° around the Z axis = small rotation.

It's possible that int(20*rand(MyRandom)) could return 1 at the first 
iteration, resulting in only a single object been placed. Try adding 
something like +2 or +3 to that value.

Possible solutions :
1) Create "Element" at some distance from the origin, or increase the 
distance that you translate it now.
2) Instead of only rotating your object, start by also randomly 
translating some distance.


Post a reply to this message

From: Sven Littkowski
Subject: Re: The Eternal Student: Loop Problem
Date: 31 Jan 2018 17:44:45
Message: <5a7246dd$1@news.povray.org>
On 29.01.2018 02:49, Thomas de Groot wrote:
> On 29-1-2018 2:24, Sven Littkowski wrote:
>> For some reason, my loop doesn't produce many items as intended, only
>> one. And I am sure, as usual I am not seeing the forest because of all
>> the trees in front of my eyes!  :-D
>>
>>
>> #declare MyRandom = seed (27053);
>> #local MyLength   = int(20*rand(MyRandom));   // Anzahl der Glieder
>> #local MyX        = rand(MyRandom)*45;
>> #local MyY        = rand(MyRandom)*1;
>> #local MyZ        = rand(MyRandom)*10;
>> #local MyElement  = 0;
>>
>> #while (MyElement<MyLength)
>>   object { Element translate < 0.0, 0.0, 0.45 > rotate < MyX, MyY, MyZ
>> > }
>>   #local MyX        = rand(MyRandom)*45;
>>   #local MyY        = rand(MyRandom)*1;
>>   #local MyZ        = rand(MyRandom)*10;
>>   #local MyElement  = MyElement+1;
>> #end
>>
> 
> All the objects are at the same location :-)
> 
> You need to randomise the translate elements too.
> 
Thanks everyone, that initial problem seems to have been solved now. :-D

---
Diese E-Mail wurde von AVG auf Viren geprüft.
http://www.avg.com


Post a reply to this message

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