Skip to content

Commit

Permalink
minor formatting and documentation, #30
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Jul 14, 2017
1 parent c90641f commit 00d8d09
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion js/common/model/MPModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ define( function( require ) {
if ( normalizedAngle < 0 ) {
normalizedAngle = ( 2 * Math.PI ) + angle;
}
assert && assert( normalizedAngle >= 0 && normalizedAngle <= 2 * Math.PI );
assert && assert( normalizedAngle >= 0 && normalizedAngle <= 2 * Math.PI, 'normalizedAngle must be between 0-2pi radians' );
return normalizedAngle;
};

Expand Down
2 changes: 1 addition & 1 deletion js/common/view/MoleculeAngleDragHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ define( function( require ) {

var previousAngle; // angle between the pointer and the molecule when the drag started

/*
/**
* Gets the angle of the pointer relative to relativeNode.
* @param {Event} event
* @returns {number} angle in radians
Expand Down
8 changes: 5 additions & 3 deletions js/common/view/PartialChargeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/**
* Visual representations of partial charge, a delta symbol followed by either + or -.
* Controls its own position in global coordinates, so clients should not attempt to position it.
* Uses static factory methods to supply the needed instances for the sim.
*
* @author Chris Malley (PixelZoom, Inc.)
*/
Expand Down Expand Up @@ -54,6 +55,7 @@ define( function( require ) {

textNode.visible = ( partialCharge !== 0 ); // invisible if dipole is zero

// Only update if there is a charge difference
if ( partialCharge !== 0 ) {

// d+ or d-
Expand Down Expand Up @@ -85,7 +87,7 @@ define( function( require ) {

return inherit( Node, PartialChargeNode, {}, {

/*
/**
* Partial charge for an atom that participates in a single bond.
* It's partial charge is the opposite of the charge of the other atom in the bond.
* The charge is placed along the axis of the bond, away from the atom.
Expand Down Expand Up @@ -114,13 +116,13 @@ define( function( require ) {
} );
},

/*
/**
* Partial charge for an atom that participates in more than one bond.
* Its partial charge is the composite of charges contributed by other atoms in the bonds.
* The charge is placed along the axis of the molecular dipole, on the opposite side of the atom from the dipole.
* @static
* @param {Atom} atom
* @param {Bond} bond
* @param {Molecule} molecule
* @returns {PartialChargeNode}
* @public
* @static
Expand Down
4 changes: 2 additions & 2 deletions js/realmolecules/view/JSmolViewerNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ define( function( require ) {
* Eg, for HF: ['1','255','255','255','9','144','224','80']
*/
var tokens = status.split( ' ' );
assert && assert( tokens.length % 4 === 0 ); // each element has 4 tokens
assert && assert( tokens.length % 4 === 0, 'each element should have 4 tokens' );

// Convert the tokens to an array of {Element}.
var elements = [];
Expand Down Expand Up @@ -402,7 +402,7 @@ define( function( require ) {
// Call this after the sim has started running
initialize: function() {

assert && assert( !this.isInitialized() );
assert && assert( !this.isInitialized(), 'already initialized' );

var self = this;

Expand Down
1 change: 1 addition & 0 deletions js/threeatoms/view/TranslateArrowsNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ define( function( require ) {

// unlink not needed
atom.locationProperty.link( function() {

// transform the arrow shapes to account for atom location and relationship to molecule location
var v = molecule.location.minus( atom.locationProperty.get() );
var angle = v.angle() - ( Math.PI / 2 );
Expand Down
4 changes: 3 additions & 1 deletion js/twoatoms/view/BondCharacterNode.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright 2014-2017, University of Colorado Boulder

/**
* Displays the bond 'character', by placing a marker on a continuum whose extremes are "covalent" and "ionic".
* Displays the bond 'character' of the molecule, by placing a marker on a continuum whose extremes are "covalent"
* and "ionic". This node is derived; the marker serves as a "readout" and is updated based on the properties
* of the molecule.
*
* @author Chris Malley (PixelZoom, Inc.)
*/
Expand Down
1 change: 1 addition & 0 deletions js/twoatoms/view/DiatomicMoleculeNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ define( function( require ) {

Node.call( this, {
children: [

// rendering order
this.electrostaticPotentialNode, this.electronDensityNode,
bondNode, atomANode, atomBNode,
Expand Down
4 changes: 2 additions & 2 deletions js/twoatoms/view/ElectronDensityNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ define( function( require ) {
*/
function ElectronDensityNode( molecule ) {

assert && assert( molecule.atomA.diameter === molecule.atomB.diameter ); // creation of gradient assumes that both atoms have the same diameter
assert && assert( molecule.atomA.diameter === molecule.atomB.diameter, 'creation of gradient assumes that both atoms have the same diameter' );

var self = this;

Expand All @@ -44,7 +44,7 @@ define( function( require ) {
this.molecule = molecule;
this.electronegativityRange = MPConstants.ELECTRONEGATIVITY_RANGE;
this.colors = MPColors.BW_GRADIENT;
assert && assert( this.colors.length === 2 ); // this implementation only works for 2 colors
assert && assert( this.colors.length === 2, 'this implementation only works for 2 colors' );

// each atom is surrounded with a 'cloud' (circle)
var radius = this.molecule.atomA.diameter * DIAMETER_SCALE / 2;
Expand Down
13 changes: 9 additions & 4 deletions js/twoatoms/view/ElectrostaticPotentialNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ define( function( require ) {
*/
function ElectrostaticPotentialNode( molecule ) {

assert && assert( molecule.atomA.diameter === molecule.atomB.diameter ); // creation of gradient assumes that both atoms have the same diameter
assert && assert( molecule.atomA.diameter === molecule.atomB.diameter,
'creation of gradient assumes that both atoms have the same diameter' );

var self = this;

Expand All @@ -44,7 +45,7 @@ define( function( require ) {
this.molecule = molecule;
this.electronegativityRange = MPConstants.ELECTRONEGATIVITY_RANGE;
this.colors = MPColors.RWB_GRADIENT;
assert && assert( this.colors.length === 3 ); // this implementation only works for 3 colors
assert && assert( this.colors.length === 3, 'this implementation only works for 3 colors' );

// each atom is surrounded with a 'cloud' (circle)
var radius = this.molecule.atomA.diameter * DIAMETER_SCALE / 2;
Expand Down Expand Up @@ -79,7 +80,10 @@ define( function( require ) {

return inherit( Node, ElectrostaticPotentialNode, {

// @public @override
/**
* @override
* @public
*/
setVisible: function( visible ) {
Node.prototype.setVisible.call( this, visible );
if ( visible ) {
Expand All @@ -88,11 +92,12 @@ define( function( require ) {
}
},

/*
/**
* Updates the surface fill. Width of the gradient expands as the difference in EN approaches zero.
* @private
*/
updateFill: function() {

// scale varies from 1 to 0, approaches zero as EN difference approaches zero.
var deltaEN = this.molecule.getDeltaEN();
if ( deltaEN === 0 ) {
Expand Down
1 change: 1 addition & 0 deletions js/twoatoms/view/TwoAtomsScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ define( function( require ) {
// Parent for all nodes added to this screen
var rootNode = new Node( {
children: [

// nodes are rendered in this order
negativePlateNode,
positivePlateNode,
Expand Down

0 comments on commit 00d8d09

Please sign in to comment.