Math.random() returns a number in the interval [0, 1), right?
So, if I need to change the interval to (-1, 1), would I use do this...
xCoord = Math.random() * 2 - 1;
to change the range to be 2 (so it'd be [0, 2) then subtract one to shift it to (-1, 1)?
So, if I need to change the interval to (-1, 1), would I use do this...
xCoord = Math.random() * 2 - 1;
to change the range to be 2 (so it'd be [0, 2) then subtract one to shift it to (-1, 1)?
Comment