diff --git a/js/faradays-law/model/Coil.js b/js/faradays-law/model/Coil.js index 89be0627..9bccc53c 100644 --- a/js/faradays-law/model/Coil.js +++ b/js/faradays-law/model/Coil.js @@ -78,7 +78,8 @@ define( function( require ) { var sign = this.magnet.flippedProperty.value ? -1 : 1; - var rSquared = this.position.distanceSquared( this.magnet.positionProperty.get() ) / (NEAR_FIELD_RADIUS * NEAR_FIELD_RADIUS); // normalized squared distance from coil to magnet + var rSquared = this.position.distanceSquared( this.magnet.positionProperty.get() ) / + (NEAR_FIELD_RADIUS * NEAR_FIELD_RADIUS); // normalized squared distance from coil to magnet // if magnet is very close to coil, then B field is at max value; if ( rSquared < 1 ) { @@ -109,7 +110,8 @@ define( function( require ) { var numberOfCoils = this.numberOfSpirals / 2; // emf = (nbr coils)*(change in B)/(change in t) - this.emfProperty.set( numberOfCoils * (this.magneticFieldProperty.get() - this.previousMagneticFieldProperty.get()) / dt ); + var changeInMagneticField = this.magneticFieldProperty.get() - this.previousMagneticFieldProperty.get(); + this.emfProperty.set( numberOfCoils * changeInMagneticField / dt ); this.previousMagneticFieldProperty.set( this.magneticFieldProperty.get() ); } } ); diff --git a/js/faradays-law/model/FaradaysLawModel.js b/js/faradays-law/model/FaradaysLawModel.js index 1fbe8b34..a2cb4665 100644 --- a/js/faradays-law/model/FaradaysLawModel.js +++ b/js/faradays-law/model/FaradaysLawModel.js @@ -124,12 +124,14 @@ define( function( require ) { * @public */ moveMagnetToPosition: function( position ) { + + // TODO: why do we subtract 1 from each of these dimensions? var magnetBounds = new Bounds2( Math.min( position.x, this.magnet.positionProperty.get().x ), Math.min( position.y, this.magnet.positionProperty.get().y ), Math.max( position.x, this.magnet.positionProperty.get().x ), Math.max( position.y, this.magnet.positionProperty.get().y ) - ).dilatedXY( this.magnet.width / 2 - 1, this.magnet.height / 2 - 1 ); // TODO: why do we subtract 1 from each of these dimensions? + ).dilatedXY( this.magnet.width / 2 - 1, this.magnet.height / 2 - 1 ); // check intersection with any restricted areas if not intersected yet if ( this.intersectedBounds === null ) { diff --git a/js/faradays-law/model/Voltmeter.js b/js/faradays-law/model/Voltmeter.js index cd7540ae..707c5b6e 100644 --- a/js/faradays-law/model/Voltmeter.js +++ b/js/faradays-law/model/Voltmeter.js @@ -35,7 +35,7 @@ define( function( require ) { // @private {number} - rad/s^2 this.needleAngularAcceleration = 0; - // @public {NumberProperty} Needle angle in radians. This drives both the needle location and the light bulb brightness. + // @public {NumberProperty} Needle angle in radians. This drives the needle location and the light bulb brightness. this.needleAngleProperty = new NumberProperty( 0, { tandem: tandem.createTandem( 'needleAngleProperty' ), units: 'radians', diff --git a/js/faradays-law/view/BulbNode.js b/js/faradays-law/view/BulbNode.js index d10cafc7..5acc2f02 100644 --- a/js/faradays-law/view/BulbNode.js +++ b/js/faradays-law/view/BulbNode.js @@ -51,7 +51,9 @@ define( function( require ) { // center of both. This was the easiest to work with. // Create the bulb body. - var bulbShape = new Shape().moveTo( 0, -BULB_NECK_WIDTH / 2 ).cubicCurveTo( -BULB_BODY_HEIGHT * 0.33, -CONTROL_POINT_Y_VALUE, -BULB_BODY_HEIGHT * 0.95, -CONTROL_POINT_Y_VALUE, -BULB_BODY_HEIGHT, 0 ).cubicCurveTo( -BULB_BODY_HEIGHT * 0.95, CONTROL_POINT_Y_VALUE, -BULB_BODY_HEIGHT * 0.33, CONTROL_POINT_Y_VALUE, 0, BULB_NECK_WIDTH / 2 ); + var bulbShape = new Shape().moveTo( 0, -BULB_NECK_WIDTH / 2 ) + .cubicCurveTo( -BULB_BODY_HEIGHT * 0.33, -CONTROL_POINT_Y_VALUE, -BULB_BODY_HEIGHT * 0.95, -CONTROL_POINT_Y_VALUE, -BULB_BODY_HEIGHT, 0 ) + .cubicCurveTo( -BULB_BODY_HEIGHT * 0.95, CONTROL_POINT_Y_VALUE, -BULB_BODY_HEIGHT * 0.33, CONTROL_POINT_Y_VALUE, 0, BULB_NECK_WIDTH / 2 ); var bulbBodyOutline = new Path( bulbShape, { stroke: 'black', lineCap: 'round' diff --git a/js/faradays-law/view/CoilsWiresNode.js b/js/faradays-law/view/CoilsWiresNode.js index 5c817600..dbf229c0 100644 --- a/js/faradays-law/view/CoilsWiresNode.js +++ b/js/faradays-law/view/CoilsWiresNode.js @@ -35,7 +35,7 @@ define( function( require ) { Node.call( this ); // bottom coil, left bottom wire - var arcPoint = new Vector2( LEFT_WIRE_BULB_START.x, view.bottomCoilEndPositions.bottomEnd.y ); // bottom coil, left bottom wire, corner point; + var arcPoint = new Vector2( LEFT_WIRE_BULB_START.x, view.bottomCoilEndPositions.bottomEnd.y ); this.addChild( new Path( new Shape() .moveToPoint( LEFT_WIRE_BULB_START ) .lineTo( arcPoint.x, arcPoint.y - ARC_RADIUS ) diff --git a/js/faradays-law/view/FlipMagnetButton.js b/js/faradays-law/view/FlipMagnetButton.js index ea8cb1e5..ede4d85e 100644 --- a/js/faradays-law/view/FlipMagnetButton.js +++ b/js/faradays-law/view/FlipMagnetButton.js @@ -69,12 +69,14 @@ define( function( require ) { .moveTo( (radius + lineWidth / 2) * Math.cos( arcStartAngle ), (radius + lineWidth / 2) * Math.sin( arcStartAngle ) ) // Inner edge of end. .arc( 0, 0, radius, arcStartAngle, arcEndAngle, false ); // Outer curve. + var matrix = Matrix3.translation( radius * Math.cos( arcEndAngle ), radius * Math.sin( arcEndAngle ) ) + .timesMatrix( Matrix3.rotation2( arcEndAngle ) ); var arrowHeadShape = new Shape() .moveTo( 0, 8 ) .lineTo( 4, 0 ) .lineTo( -4, 0 ) .close() - .transformed( Matrix3.translation( radius * Math.cos( arcEndAngle ), radius * Math.sin( arcEndAngle ) ).timesMatrix( Matrix3.rotation2( arcEndAngle ) ) ); + .transformed( matrix ); return new Node( { children: [ new Path( arcShape, { stroke: '#000', diff --git a/js/faradays-law/view/MagnetNodeWithField.js b/js/faradays-law/view/MagnetNodeWithField.js index 99721d48..9f870bd4 100644 --- a/js/faradays-law/view/MagnetNodeWithField.js +++ b/js/faradays-law/view/MagnetNodeWithField.js @@ -124,7 +124,10 @@ define( function( require ) { magnetOffset.y = self.globalToParentPoint( event.pointer.point ).y - self.centerY; // if the user starts the drag on the magnet itself (not on the arrows), we make the arrows invisible - if ( event.target !== magnetTopArrowNode && event.target !== magnetBottomArrowNode && event.target !== magnetRightArrowNode && event.target !== magnetLeftArrowNode ) { + if ( event.target !== magnetTopArrowNode && + event.target !== magnetBottomArrowNode && + event.target !== magnetRightArrowNode && + event.target !== magnetLeftArrowNode ) { model.showMagnetArrowsProperty.set( false ); } }, diff --git a/js/faradays-law/view/VoltmeterNode.js b/js/faradays-law/view/VoltmeterNode.js index f2d7f19d..68ec602a 100644 --- a/js/faradays-law/view/VoltmeterNode.js +++ b/js/faradays-law/view/VoltmeterNode.js @@ -80,7 +80,7 @@ define( function( require ) { // position and add the label label.centerX = 0; - label.centerY = (readoutBackground.bottom + background.bottom) * 0.48; // position a little above exactly between edges + label.centerY = (readoutBackground.bottom + background.bottom) * 0.48; // When the text changes (via PhET-iO), re-center it label.on( 'text', function() {