POV-Ray : Newsgroups : povray.general : The Eternal Student: Loop Problem Server Time: 20 Jun 2019 19:05:31 GMT
 The Eternal Student: Loop Problem (Message 1 to 7 of 7)
 From: Sven Littkowski Subject: The Eternal Student: Loop Problem Date: 29 Jan 2018 01: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
```
 From: Thomas de Groot Subject: Re: The Eternal Student: Loop Problem Date: 29 Jan 2018 07: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
```
 From: Sven Littkowski Subject: Re: The Eternal Student: Loop Problem Date: 29 Jan 2018 08: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
```
 From: Sven Littkowski Subject: Re: The Eternal Student: Loop Problem Date: 29 Jan 2018 08:38:51 Message: <5a6edd9b@news.povray.org>
```Problem solved, thanks a lot! :-D
```
 From: Kontemplator Subject: Re: The Eternal Student: Loop Problem Date: 29 Jan 2018 12:05:00 Message:
```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));
```
 From: Alain Subject: Re: The Eternal Student: Loop Problem Date: 29 Jan 2018 22: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.
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.
translating some distance.
```
 From: Sven Littkowski Subject: Re: The Eternal Student: Loop Problem Date: 31 Jan 2018 22: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
```