MIssing Operators

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

MIssing Operators

stonysmith
I would like to throw my $0.02 into the pot. In no way do I want to belittle the fantastic work that has been done to date. OpenSCAD answers a need I've had for a long time... it's a wonderful tool.

I don't think that it would 'pervert' the usage of OpenSCAD if we had assignable variables similiar to other languages. In truth, it's not that big of a change to the language, and it's not all that hard to implement. After all, Microsoft figured it out in 1978. <grin> My vote would be that we DO add classical variables.

The other thing that is critically needed for OpenSCAD is a Random() function that returns a psuedo-random value between 0.0 and 1.0.. this would answer several people's request for 'organic' structures, etc.

The third thing I'd like to see is the ability to set start_angle and end_angle for the rotate_extrude function. I don't want to only make donuts.. I want to make elbow macaroni. <grin>
Reply | Threaded
Open this post in threaded view
|

Re: MIssing Operators

Steven Dick


On Wed, Sep 15, 2010 at 12:29 AM, <[hidden email]> wrote:
The other thing that is critically needed for OpenSCAD is a Random() f

that would be nice, and probably easy too.
 
The third thing I'd like to see is the ability to set start_angle and end_angle for the rotate_extrude function.

I've been doing that by cutting out wedges and cubes from the donut, but I agree, that would help a lot.

Reply | Threaded
Open this post in threaded view
|

Re: MIssing Operators

andy@kirbyand.co.uk
In reply to this post by stonysmith
All sounds cool to me.

--
Like a rolling stone
----- Original message -----

> I would like to throw my $0.02 into the pot. In no way do I want to   
> belittle the fantastic work that has been done to date. OpenSCAD answers
> a     need I've had for a long time... it's a wonderful tool.
>
> I don't think that it would 'pervert' the usage of OpenSCAD if we had   
> assignable variables similiar to other languages. In truth, it's not
> that     big of a change to the language, and it's not all that hard to
> implement.     After all, Microsoft figured it out in 1978. <grin> My vote
> would be that     we DO add classical variables.
>
> The other thing that is critically needed for OpenSCAD is a Random()   
> function that returns a psuedo-random value between 0.0 and 1.0.. this   
> would answer several people's request for 'organic' structures, etc.
>
> The third thing I'd like to see is the ability to set start_angle and   
> end_angle for the rotate_extrude function. I don't want to only make   
> donuts.. I want to make elbow macaroni. <grin>


Reply | Threaded
Open this post in threaded view
|

Re: MIssing Operators

Giles Bathgate-2
In reply to this post by stonysmith
The attached patch adds a rand() function to OpenSCAD

I expect that most people will use it like so:

module main()
{
  echo(rand(1,100));
  echo(rand(1,100));
  echo(rand(1,100));
}

main();

The output of this will be different each time you compile the script
but for example

ECHO: 42.3678
ECHO: 16.6152
ECHO: 59.3326
 

The form is rand(min,max) where min is the minimum value and max is the
maximum value

However, some people might want a set of random numbers that are rooted
at a specific seed, in which case you can use the form
rand(min,max,seed) this would be used like this:

module main()
{
  echo(rand(1,100,2));
  echo(rand(1,100));
  echo(rand(1,100));
}

i.e. subsequent calls after a seed has been set should not pass a value
for seed.

The output of this will always be the same:
ECHO: 42.3678
ECHO: 16.6152
ECHO: 59.3326

(unless of course you use a different seed)

A further improvement might be to add a form rands(min,max,seed,amount)
which would return a Vector (array  or list) with 'amount' number of
elements

Regards

Giles  






rand.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: MIssing Operators

clothbot
Wicked!  Very much looking forward to using this!

Andrew.

On 2010-09-17, at 2:33 PM, Giles Bathgate wrote:

> The attached patch adds a rand() function to OpenSCAD
>
> I expect that most people will use it like so:
>
> module main()
> {
>  echo(rand(1,100));
>  echo(rand(1,100));
>  echo(rand(1,100));
> }
>
> main();
>
> The output of this will be different each time you compile the script
> but for example
>
> ECHO: 42.3678
> ECHO: 16.6152
> ECHO: 59.3326
>
>
> The form is rand(min,max) where min is the minimum value and max is the
> maximum value
>
> However, some people might want a set of random numbers that are rooted
> at a specific seed, in which case you can use the form
> rand(min,max,seed) this would be used like this:
>
> module main()
> {
>  echo(rand(1,100,2));
>  echo(rand(1,100));
>  echo(rand(1,100));
> }
>
> i.e. subsequent calls after a seed has been set should not pass a value
> for seed.
>
> The output of this will always be the same:
> ECHO: 42.3678
> ECHO: 16.6152
> ECHO: 59.3326
>
> (unless of course you use a different seed)
>
> A further improvement might be to add a form rands(min,max,seed,amount)
> which would return a Vector (array  or list) with 'amount' number of
> elements
>
> Regards
>
> Giles  
>
>
>
>
>
> <rand.patch>_______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://rocklinux.net/mailman/listinfo/openscad

--

"The future is already here.  It's just not very evenly distributed" -- William Gibson

Me: http://clothbot.com/wiki/