Skip to content

Commit

Permalink
reformt Random to be in dot namespace, see phetsims/states-of-matter#100
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsamuel137 committed Jun 19, 2015
1 parent 8a79988 commit 3632977
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
52 changes: 28 additions & 24 deletions js/Random.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,41 @@ define( function( require ) {
'use strict';

// modules
var inherit = require( 'PHET_CORE/inherit' );
var Util = require( 'DOT/Util' );
var dot = require( 'DOT/dot' );

function Random() {
}
dot.Random = function Random() {
};
var Random = dot.Random;

return inherit( Object, Random,
{
nextBoolean: function() {
return Math.random() >= 0.5;
},
Random.prototype = {

nextInt: function( n ) {
var value = Math.random() * n;
return value | 0; // convert to int
},
constructor: Random,

nextDouble: function() {
return Math.random();
},
nextBoolean: function() {
return Math.random() >= 0.5;
},

/**
* @public
* @returns {number}
*/
nextGaussian: function() {
// random gaussian with mean = 0 and standard deviation = 1
return Util.boxMullerTransform( 0, 1 );
}
nextInt: function( n ) {
var value = Math.random() * n;
return value | 0; // convert to int
},

} );
nextDouble: function() {
return Math.random();
},

/**
* @public
* @returns {number}
*/
nextGaussian: function() {
// random gaussian with mean = 0 and standard deviation = 1
return Util.boxMullerTransform( 0, 1 );
}

};

return Random;

} );
1 change: 1 addition & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ define( [
'DOT/Plane3',
'DOT/QRDecomposition',
'DOT/Quaternion',
'DOT/Random',
'DOT/Ray2',
'DOT/Ray3',
'DOT/Rectangle',
Expand Down

0 comments on commit 3632977

Please sign in to comment.