[OpenSCAD] round(rands)

Chris Thompson eagleapex at gmail.com
Mon Jul 16 22:48:19 CEST 2012


ok. But rands could create a vector with a single number in it, and it
still needs to be handled as a vector, right?

I also notice that rands() does't ever recalculate a different number.
It always acts like there is a seed declared.
I made a module with a random number of elements, but each time the
module is called with rands() inside, it is the same number.
Is there a way to get new random numbers?

Chris Thompson, eagleapex.com
GPG key available
"Obscurity is a far greater threat to authors and creative artists
than piracy" -Tim O'Reilly


On Mon, Jul 16, 2012 at 4:37 PM, Giles Bathgate
<giles.bathgate at gmail.com> wrote:
> Chris
>
> Good, except your terminology is a bit misleading a vector is
> synonymous to an array or a list. A vector is not a single number.
>
> Regards
>
> Giles
>
> On 16 July 2012 21:30, Chris Thompson <eagleapex at gmail.com> wrote:
>> OK, like an Array?
>>         num1 = rands(2,10,1,6747);
>>         num7 = round(num1[0]);
>>     echo(num1[0]);
>>     echo(num7);
>> provides:
>> ECHO: 2.422436106950045
>> ECHO: 2
>>
>> I added a bit of explanation to the User Manual.
>>
>> Thanks!
>>
>> Chris Thompson, eagleapex.com
>> GPG key available
>> "Obscurity is a far greater threat to authors and creative artists
>> than piracy" -Tim O'Reilly
>>
>>
>> On Mon, Jul 16, 2012 at 4:17 PM, Giles Bathgate
>> <giles.bathgate at gmail.com> wrote:
>>> Chris
>>>
>>> rands returns a vector (list) of random numbers even though you are
>>> telling it to return one random number in the list.
>>>
>>> you need to do:
>>>
>>> list=rands(2,10,1,6747);
>>>
>>> num1=list[0];
>>>
>>> etc...
>>>
>>> Regards
>>>
>>> Giles
>>>
>>> On 16 July 2012 21:12, Chris Thompson <eagleapex at gmail.com> wrote:
>>>> I can't round a random number.
>>>>
>>>>         num1 = rands(2,10,1,6747);
>>>>         num2 = 9.58674394;
>>>>         num3 = round(num1);
>>>>         num4 = round(num2);
>>>>     echo(num1);
>>>>     echo(num2);
>>>>     echo(num3);
>>>>     echo(num4);
>>>>
>>>> this provides:
>>>> ECHO: [2.422436106950045]
>>>> ECHO: 9.58674394
>>>> ECHO: undef
>>>> ECHO: 10
>>>>
>>>> I don't see anything wrong with trying to get a random integer with
>>>> this method. Is this a bug?
>>>>
>>>>
>>>> Chris Thompson, eagleapex.com
>>>> GPG key available
>>>> "Obscurity is a far greater threat to authors and creative artists
>>>> than piracy" -Tim O'Reilly
>>>> _______________________________________________
>>>> OpenSCAD mailing list
>>>> OpenSCAD at rocklinux.org
>>>> http://rocklinux.net/mailman/listinfo/openscad
>>>> http://openscad.org - https://flattr.com/thing/121566
>>> _______________________________________________
>>> OpenSCAD mailing list
>>> OpenSCAD at rocklinux.org
>>> http://rocklinux.net/mailman/listinfo/openscad
>>> http://openscad.org - https://flattr.com/thing/121566
>> _______________________________________________
>> OpenSCAD mailing list
>> OpenSCAD at rocklinux.org
>> http://rocklinux.net/mailman/listinfo/openscad
>> http://openscad.org - https://flattr.com/thing/121566
> _______________________________________________
> OpenSCAD mailing list
> OpenSCAD at rocklinux.org
> http://rocklinux.net/mailman/listinfo/openscad
> http://openscad.org - https://flattr.com/thing/121566


More information about the OpenSCAD mailing list