{I add - I actually like this a little better. Although I think a good
compiler would optimise them to be the same thing anyway)
--
Justin Couch http://www.vlc.com.au/~justin/
Freelance Java Consultant http://www.yumetech.com/
Author, Java 3D FAQ Maintainer http://www.j3d.org/
-------------------------------------------------------------------
"Humanism is dead. Animals think, feel; so do machines now.
Neither man nor woman is the measure of all things. Every organism
processes data according to its domain, its environment; you, with
all your brains, would be useless in a mouse's universe..."
- Greg Bear, Slant
-------------------------------------------------------------------
--- Begin Message ---
Hello Justin!
Can you please send this to Java3D list for me. I get messages from the list
but have difficulties sending to it, since there are obviously problems at
my provider...
thanks,
Jure
> > My prog requires random graph coordinates. I am creating a Random
sequence
> > and then pulling them off the sequence using nextFloat(). Does anyone
know
> > how to randomise the sign (positive or negative)?
>
> Just use another random boolean.
>
>
> boolean sign = Random.nextBoolean();
>
>
> float my_float = Random.nextFloat * (sign ? +1 : -1);
Or without multiplication (in case you're doing it in a loop):
float my_float = (sign ? Random.nextFloat : -Random.nextFloat);
or
float my_float = Random.nextFloat;
my_float = (sign ? +myfloat : -myfloat);
Jure
--- End Message ---