Skip to content

Commit

Permalink
Adjusted line lengths, see #86
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Nov 21, 2017
1 parent eb33adf commit fd4d518
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 9 deletions.
6 changes: 4 additions & 2 deletions js/faradays-law/model/Coil.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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() );
}
} );
Expand Down
4 changes: 3 additions & 1 deletion js/faradays-law/model/FaradaysLawModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
2 changes: 1 addition & 1 deletion js/faradays-law/model/Voltmeter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 3 additions & 1 deletion js/faradays-law/view/BulbNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion js/faradays-law/view/CoilsWiresNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
4 changes: 3 additions & 1 deletion js/faradays-law/view/FlipMagnetButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 4 additions & 1 deletion js/faradays-law/view/MagnetNodeWithField.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
},
Expand Down
2 changes: 1 addition & 1 deletion js/faradays-law/view/VoltmeterNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit fd4d518

Please sign in to comment.