Skip to content

Commit

Permalink
added visibility annotations see issue #62
Browse files Browse the repository at this point in the history
  • Loading branch information
aadish committed Mar 9, 2016
1 parent 212a91a commit dc97b0d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
25 changes: 16 additions & 9 deletions js/gravity-force-lab/model/GravityForceLabModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,18 @@ define( function( require ) {
* @constructor
*/
function GravityForceLabModel() {

var self = this;
this.massRange = new Range( 1, 1000 );
this.massRange = new Range( 1, 1000 ); // @public

PropertySet.call( this, {
force: 0,
showValues: true,
constantRadius: false,
ruler: { x: 120, y: 270 }
force: 0, // @public (read-only)
showValues: true, // @public
constantRadius: false, // @public
ruler: { x: 120, y: 270 } // @public
} );

this.mass1 = new Mass( 50, -2, '#00f', this.constantRadiusProperty );
this.mass2 = new Mass( 200, 2, '#f00', this.constantRadiusProperty );
this.mass1 = new Mass( 50, -2, '#00f', this.constantRadiusProperty ); // @public
this.mass2 = new Mass( 200, 2, '#f00', this.constantRadiusProperty ); // @public

this.mass1.massProperty.link( function(){ self.updateForce(); } );
this.mass2.massProperty.link( function(){ self.updateForce(); } );
Expand All @@ -61,8 +60,11 @@ define( function( require ) {

return inherit( PropertySet, GravityForceLabModel, {

/**
* step function makes sure masses doesn't goes out of bounds and don't overlap each other at each time step
* @public
*/
step: function() {
// making sure masses doesn't goes out of bounds and don't overlap each other
var minX = LEFT_BOUNDARY + PULL_OBJECT_WIDTH + this.mass1.radius;
var maxX = RIGHT_BOUNDARY - PULL_OBJECT_WIDTH - this.mass2.radius;
var locationMass1 = this.mass1.position;
Expand Down Expand Up @@ -100,11 +102,16 @@ define( function( require ) {
this.mass2.positionProperty.set( locationMass2 );
},

/**
* updateForce calculates the force between the objects and update the force variable
* @private
*/
updateForce: function() {
var distance = calculateDistance( this.mass1.position, this.mass2.position );
this.force = calculateForce( this.mass1.mass, this.mass2.mass, distance );
},

// @public
reset: function() {
PropertySet.prototype.reset.call( this );
this.mass1.reset();
Expand Down
16 changes: 10 additions & 6 deletions js/gravity-force-lab/model/Mass.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ define( function( require ) {
var self = this;
var initialRadius = this.calculateRadius( initialMass );
PropertySet.call( this, {
mass: initialMass,
position: initialPosition,
radius: initialRadius,
baseColor: new Color( baseColor )
mass: initialMass, // @public
position: initialPosition, // @public
radius: initialRadius, // @public (read-only)
baseColor: new Color( baseColor ) // @public (read-only)
});

this.massProperty.lazyLink( function( mass ){
Expand Down Expand Up @@ -63,12 +63,16 @@ define( function( require ) {

return inherit( PropertySet, Mass, {

// calculates the radius based on mass of object maintaining constant density
// calculations are made using the density formula and volume of a sphere
/**
* calculates the radius based on mass of object maintaining constant density
* calculations are made using the density formula and volume of a sphere
* @private
*/
calculateRadius: function( mass ) {
return Math.pow( ( mass * 3 * 7 / DENSITY / 4 / 22 ), 1/3);
},

// @public
reset: function() {
PropertySet.prototype.reset.call( this );
}
Expand Down

0 comments on commit dc97b0d

Please sign in to comment.