Thanks Justin

-----Original Message-----
From: Discussion list for Java 3D API
[mailto:[EMAIL PROTECTED]]On Behalf Of Justin Couch
Sent: Friday, January 11, 2002 9:01 PM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] random numbers


stuart wrote:


> 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);

--
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
-------------------------------------------------------------------

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to