Three.js: [Documentation]: Question about Math.random().

Created on 6 Apr 2020  路  5Comments  路  Source: mrdoob/three.js

MDN - Math.random() says the function returns a a floating-point number in the range 0 to less than 1 (inclusive of 0, but not 1), MDN doesn't describe in math expression.

https://github.com/mrdoob/three.js/blob/aec286294515e5a4f60a00e7daf05fe1558e9aaa/docs/api/en/math/Vector2.html#L337

I am not sure it make sense or better, change a random value [0-1] to a random value [0-1) , a random value [0~1) or a random value [0,1).

How about Sets the x and y components of this vector to a random value in the range 0 to less than 1 (inclusive of 0, but not 1).

Documentation

Most helpful comment

I wouldn't think mathematicians are the target users of the library...
I wouldn't know what [0, 1) means. I think it's helpful to say a value between 0 and 1, excluding 1.

All 5 comments

I would prefer [0, 1) which is the correct mathematical definition for the value range of Math.random().

I suggest the following simple statement, which I think is adequate:

Sets each component of this vector to a pseudo-random value in [0, 1).

I wouldn't think mathematicians are the target users of the library...
I wouldn't know what [0, 1) means. I think it's helpful to say a value between 0 and 1, excluding 1.

2nd attempt: :-)

Sets each component of this vector to a pseudo-random value between 0 and 1, excluding 1.

My simple brain can understand that! 馃榿馃憣

Was this page helpful?
0 / 5 - 0 ratings