Skip to content

Commit

Permalink
Enhance readability of some single line comments, see issue #27
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegreenberg committed Sep 25, 2015
1 parent 41dc8e6 commit c985ea5
Show file tree
Hide file tree
Showing 11 changed files with 176 additions and 172 deletions.
2 changes: 1 addition & 1 deletion js/trig-tour/TrigTourScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ define( function( require ) {
*/
function TrigTourScreen() {

//If this is a single-screen sim, no icon is necessary.
// If this is a single-screen sim, no icon is necessary.
var icon = null;

Screen.call( this, trigLabSimString, icon,
Expand Down
16 changes: 8 additions & 8 deletions js/trig-tour/model/TrigTourModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ define( function( require ) {
setFullAngle: function( smallAngle ) {
this.smallAngle = smallAngle;

//must be less than (180-30)deg in order to handle special angle correctly
// must be less than (180-30)deg in order to handle special angle correctly
var comparisonAngle = 149 * Math.PI / 180;
if ( ( this.smallAngle < 0 ) && (this.previousAngle > comparisonAngle) ) {
this.rotationNumberFromPi += 1;
Expand All @@ -173,10 +173,10 @@ define( function( require ) {
this.rotationNumberFromPi -= 1;
}

//don't want to trigger angle update yet
// don't want to trigger angle update yet
var targetAngle = this.rotationNumberFromPi * 2 * Math.PI + this.smallAngle;

//round to nearest half-degree; to do this, must convert to degrees and then back to rads
// round to nearest half-degree; to do this, must convert to degrees and then back to rads
var roundedTargetAngle = targetAngle * 180 / Math.PI;
var deltaDeg = 0.5;
var roundFactor = Util.roundSymmetric( 1 / deltaDeg );
Expand All @@ -202,13 +202,13 @@ define( function( require ) {
var nearestSpecialAngleInRads = 0;
var specialAngles = [ -150, -135, -120, -90, -60, -45, -30, 0, 30, 45, 60, 90, 120, 135, 150, 180 ];

//borders are angles half-way between special angles
// borders are angles half-way between special angles
var borders = [ -165, -142.5, -127.5, -105, -75, -52.5, -37.5, -15, 15, 37.5, 52.5, 75, 105, 127.5, 142.5, 165 ];
for ( var i = 0; i < specialAngles.length; i++ ) {
if ( smallAngleInDegs >= borders[ i ] && smallAngleInDegs < borders[ i + 1 ] ) {
nearestSpecialAngleInRads = specialAngles[ i ] * Math.PI / 180;
}
//Must deal with angle = 180 deg as a special case.
// Must deal with angle = 180 deg as a special case.
if ( smallAngleInDegs >= 165 || smallAngleInDegs < -165 ) {
nearestSpecialAngleInRads = Math.PI;
}
Expand All @@ -227,10 +227,10 @@ define( function( require ) {
var remainderInDegrees = remainderAngle * 180 / Math.PI;
var nearestSpecialAngleInDegrees = 0;

//Notice these are not the same special angles as in setSpecialAngle() above
// Notice these are not the same special angles as in setSpecialAngle() above
var specialAngles = [ 0, 30, 45, 60, 90, 120, 135, 150, 180, 210, 225, 240, 270, 300, 315, 330, 360 ];

//borders are angles half-way between special angles
// borders are angles half-way between special angles
var borders = [ 15, 37.5, 52.5, 75, 105, 127.5, 142.5, 165, 195, 217.5, 232.5, 255, 285, 307.5, 322.5, 345 ];

for ( var i = 0; i <= specialAngles.length - 1; i++ ) {
Expand All @@ -242,7 +242,7 @@ define( function( require ) {
}
}

//Must handle 0 and +/-360 deg angles as special cases.
// Must handle 0 and +/-360 deg angles as special cases.
if ( remainderInDegrees < 15 && remainderInDegrees >= -15 ) {
nearestSpecialAngleInDegrees = 0;
}
Expand Down
24 changes: 12 additions & 12 deletions js/trig-tour/view/ArrowLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ define( function( require ) {
var arrowLine = this;
this.vertical = ( orientation === 'v' ); // @private
options = _.extend( {
//if arrow length shorter than criticalFactor times arrow head length, then start scaling arrowLine
// if arrow length shorter than criticalFactor times arrow head length, then start scaling arrowLine
criticalFactor: 2,
arrowHeadLength: 25 //arrow head length in pixels
arrowHeadLength: 25 // arrow head length in pixels
}, options );
this.options = options;

Expand All @@ -42,14 +42,14 @@ define( function( require ) {
this.arrowHeadLength = options.arrowHeadLength;
this.arrowHeadWidth = (3 / 5) * this.arrowHeadLength;

//arrowLine consists of Line and triangular arrowHead Path
// arrowLine consists of Line and triangular arrowHead Path
this.line = new Line( 0, 0, 0, 0, options );
this.arrowHeadShape = new Shape();
this.arrowHead = new Path( this.arrowHeadShape, { lineWidth: 1, fill: this.line.stroke } );

arrowLine.drawArrowHead( this.arrowHeadLength );

//place arrowHead on end of Line
// place arrowHead on end of Line
if ( this.vertical ) {
this.arrowHead.y = defaultLength;
}
Expand All @@ -59,10 +59,10 @@ define( function( require ) {
this.canvas = new Node();
this.line.addChild( this.arrowHead );

//overlay invisible rectangle on top of line, to activate mouse cursor
// overlay invisible rectangle on top of line, to activate mouse cursor
this.mouseMarker = new Rectangle( -10, -50, 20, 100, { fill: 'green', opacity: 0, cursor: 'pointer' } );

//need mouse pointer active only for vertical line in graphView
// need mouse pointer active only for vertical line in graphView
if ( orientation === 'v' ) {
this.line.addChild( this.mouseMarker );
}
Expand All @@ -77,12 +77,12 @@ define( function( require ) {
this.arrowHead.fill = color;
},

//set position of tip of arrow head and size arrow appropriately
//displacement is signed length of arrow, + if arrow points right/up, or - if arrow points left/down
// set position of tip of arrow head and size arrow appropriately
// displacement is signed length of arrow, + if arrow points right/up, or - if arrow points left/down
setEndPoint: function( displacement ) {
var sign = 0; //+1, -1, or zero depending on sign of displacement
var sign = 0; // +1, -1, or zero depending on sign of displacement
if ( displacement !== 0 ) {
//sign = +1 if arrow pointing up or right, -1 if pointing down or left
// sign = +1 if arrow pointing up or right, -1 if pointing down or left
sign = Util.roundSymmetric( displacement / Math.abs( displacement ) );
}
this.arrowHead.setRotation( (sign - 1) * Math.PI / 2 );
Expand All @@ -91,7 +91,7 @@ define( function( require ) {
if ( this.vertical ) {
if ( length > this.criticalFactor * this.arrowHeadLength ) { //if arrow long enough
this.drawArrowHead( this.arrowHeadLength );
//factor of 0.9 so that arrowHead overlaps line slightly
// factor of 0.9 so that arrowHead overlaps line slightly
this.line.setPoint2( 0, -displacement + 0.9 * sign * this.arrowHeadLength );
if ( sign > 0 ) {
this.mouseMarker.setRect( -10, -length, 20, length );
Expand All @@ -101,7 +101,7 @@ define( function( require ) {
}
this.arrowHead.y = -displacement;
}
else { //if arrow too small for arrowHead to fit
else { // if arrow too small for arrowHead to fit
scaleFactor = Math.max( 0.1, length / ( this.criticalFactor * this.arrowHeadLength ) );
this.drawArrowHead( this.arrowHeadLength * scaleFactor );
this.arrowHead.y = -displacement;
Expand Down
6 changes: 3 additions & 3 deletions js/trig-tour/view/ControlPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ define( function( require ) {

this.viewProperties = viewProperties;

//A cluster of 3 radio buttons for displaying either cos, sin or tan
//viewProperties.graph = 'cos'|'sin'|'tan'
// A cluster of 3 radio buttons for displaying either cos, sin or tan
// viewProperties.graph = 'cos'|'sin'|'tan'
var myRadioButtonOptions = { radius: 10, fontSize: 15, deselectedColor: 'white' };
var cosRadioButton = new AquaRadioButton( viewProperties.graphProperty, 'cos', cosText, myRadioButtonOptions );
var sinRadioButton = new AquaRadioButton( viewProperties.graphProperty, 'sin', sinText, myRadioButtonOptions );
var tanRadioButton = new AquaRadioButton( viewProperties.graphProperty, 'tan', tanText, myRadioButtonOptions );

//3 checkboxes: Labels, Grid, Special Angles
// 3 checkboxes: Labels, Grid, Special Angles
var checkBoxOptions = { checkBoxColorBackground: 'white' };
var labelsCheckBox = new CheckBox( labelsText, viewProperties.labelsVisibleProperty, checkBoxOptions );
var gridCheckBox = new CheckBox( gridText, viewProperties.gridVisibleProperty, checkBoxOptions );
Expand Down
32 changes: 18 additions & 14 deletions js/trig-tour/view/FractionNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ define( function( require ) {
this.options = options;
this.fractionNode = this;

// Call the super constructor
// call the super constructor
Node.call( this.fractionNode );

this.numerator = numerator;
this.denominator = denominator;

//create the fraction
// create the fraction
this.setFraction();

this.mutate( options );
Expand Down Expand Up @@ -73,20 +73,23 @@ define( function( require ) {
var squareRootSignNeeded = false; // true if square root symbol is needed over the numerator
var denominatorNeeded = true; // true if only the numerator is displayed as a fractional number

//Check that arguments are strings
// Check that arguments are strings
if ( typeof this.numerator !== 'string' ) { this.numerator = this.numerator.toString(); }
if ( typeof this.denominator !== 'string' ) { this.denominator = this.denominator.toString(); }

//Process leading minus sign and square root tag
if ( this.numerator.charAt( 0 ) === '-' ) { //remove minus sign, if found
// Process leading minus sign and square root tag
if ( this.numerator.charAt( 0 ) === '-' ) {
//remove minus sign, if found
this.numerator = this.numerator.slice( 1 );
numeratorNegative = true;
}
if ( this.denominator.charAt( 0 ) === '-' ) { //remove minus sign, if found
if ( this.denominator.charAt( 0 ) === '-' ) {
//remove minus sign, if found
this.denominator = this.denominator.slice( 1 );
denominatorNegative = true;
}
if ( this.numerator.charAt( 0 ) === 'q' ) { //remove squareRoot tag, if found
if ( this.numerator.charAt( 0 ) === 'q' ) {
//remove squareRoot tag, if found
this.numerator = this.numerator.slice( 1 );
squareRootSignNeeded = true;
}
Expand All @@ -100,7 +103,7 @@ define( function( require ) {
minusSignNeeded = true;
}

//Draw minus sign to go in front of fraction, if needed.
// Draw minus sign to go in front of fraction, if needed.
var length = 8;
var midHeight = 7;
if ( minusSignNeeded ) {
Expand All @@ -111,25 +114,26 @@ define( function( require ) {
} );
}
else {
minusSign = new Line( 0, 0, 0, 0 ); //just a placeholder is no minus sign
// just a placeholder is no minus sign
minusSign = new Line( 0, 0, 0, 0 );
}

//Draw horizontal line separating numerator and denominator
// Draw horizontal line separating numerator and denominator
if ( squareRootSignNeeded ) {
length = 1.8 * this.numeratorText.width;
}
else {
length = 1.2 * this.numeratorText.width;
}

//dividing bar
// dividing bar
var bar = new Line( 0, -midHeight, length, -midHeight, {
stroke: TrigTourColors.LINE_COLOR,
lineWidth: 2,
lineCap: 'round'
} );

//draw square root symbol
// draw square root symbol
var sqRtShape = new Shape();
if ( squareRootSignNeeded ) {
var W = 1.2 * this.numeratorText.width;
Expand All @@ -139,9 +143,9 @@ define( function( require ) {
}
var sqRtPath = new Path( sqRtShape, { stroke: TrigTourColors.LINE_COLOR, lineWidth: 1, lineCap: 'round' } );

//if no denominator argument is passed in, then display the numerator as a non-fraction number
// if no denominator argument is passed in, then display the numerator as a non-fraction number
if ( this.denominator === undefined || this.denominator === '' ) {
//make current children invisible so numerator is not obscured
// make current children invisible so numerator is not obscured
denominatorNeeded = false;
for ( var i = 0; i < this.children.length; i++ ) {
this.children[ i ].visible = false;
Expand Down
Loading

0 comments on commit c985ea5

Please sign in to comment.