Skip to content

Commit

Permalink
add distanceProperty, phetsims/gravity-force-lab#76
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Aug 22, 2019
1 parent b0234ac commit 1865320
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions js/model/ISLCModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ define( require => {
minSeparationBetweenObjects: 0.1 // in meters
}, options );

assert && assert( object1.positionProperty.units === object2.positionProperty.units, 'units should be the same' );

// @public (read-only)
this.leftObjectBoundary = locationRange.min;
this.rightObjectBoundary = locationRange.max;
Expand Down Expand Up @@ -86,6 +88,17 @@ define( require => {
phetioDocumentation: 'The force of one object on the other (in Newtons)'
} );

// @private {Property.<number>} - The distance between the two objects. Added for PhET-iO.
this.distanceProperty = new DerivedProperty( [
this.object1.positionProperty,
this.object2.positionProperty
], ( p1, p2 ) => Math.abs( p2 - p1 ), {
phetioType: DerivedPropertyIO( NumberIO ),
tandem: tandem.createTandem( 'distanceProperty' ),
units: object1.positionProperty.units,
phetioDocumentation: 'The distance between the two objects\' centers'
} );

const updateRange = object => {
const maxPosition = this.getObjectMaxPosition( object );
const minPosition = this.getObjectMinPosition( object );
Expand Down

0 comments on commit 1865320

Please sign in to comment.