Skip to content

Commit

Permalink
Rename range => physicalRange, see #45
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Mar 4, 2022
1 parent 9e894a2 commit 4014603
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 14 deletions.
3 changes: 2 additions & 1 deletion js/common/CASQueryParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import centerAndSpread from '../centerAndSpread.js';
const CASQueryParameters = QueryStringMachine.getAll( {

// TODO: It would be nice if QueryStringMachine supported mapping to EnumerationValue
// TODO: Or should we bring back StringEnumerationProperty in https://github.com/phetsims/axon/issues/373?
// SR: Or should we bring back StringEnumerationProperty in https://github.com/phetsims/axon/issues/373?
// SR: Or both?
plotType: {
type: 'string',
validValues: [ 'dotPlot', 'linePlot' ],
Expand Down
2 changes: 1 addition & 1 deletion js/common/model/AnimationMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import centerAndSpread from '../../centerAndSpread.js';
export class AnimationMode extends EnumerationValue {

// TODO: SR would like to re-evaluate StringEnumerationValue, see https://github.com/phetsims/axon/issues/373
// TODO: But more importantly, this sim should be consistent.
// SR: But more importantly, this sim should be consistent.
static FLYING = new AnimationMode();
static STACKING = new AnimationMode();
static RETURNING = new AnimationMode();
Expand Down
10 changes: 5 additions & 5 deletions js/common/model/CASModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class CASModel {
readonly maxNumberOfObjects: number;

// TODO: rename to allowedRange or something
readonly range: Range;
readonly physicalRange: Range;

// This is the number that we can still add to the PhetioGroup
readonly numberOfRemainingObjectsProperty: DerivedProperty<number, [ count: number ]>;
Expand Down Expand Up @@ -110,7 +110,7 @@ class CASModel {
tandem: options.includeCards ? options.tandem.createTandem( 'cardModelGroup' ) : Tandem.OPT_OUT
} );

this.range = new Range( 1, 15 );
this.physicalRange = new Range( 1, 15 );

this.isSortingDataProperty = new BooleanProperty( false, {
tandem: options.tandem.createTandem( 'isSortingDataProperty' )
Expand Down Expand Up @@ -146,11 +146,11 @@ class CASModel {
} );
this.dataRangeProperty = new Property<Range | null>( null );
this.medianPredictionProperty = new NumberProperty( 1, {
range: this.range,
range: this.physicalRange,
tandem: options.tandem.createTandem( 'medianPredictionProperty' )
} );
this.meanPredictionProperty = new NumberProperty( 1, {
range: this.range,
range: this.physicalRange,
tandem: options.tandem.createTandem( 'meanPredictionProperty' )
} );

Expand Down Expand Up @@ -291,7 +291,7 @@ class CASModel {
const casObject = this.objectGroup.createNextElement( this.objectType, options );

const dragPositionListener = ( dragPosition: Vector2, oldPosition: Vector2 ) => {
casObject.valueProperty.value = Utils.roundSymmetric( this.range.constrainValue( dragPosition.x ) );
casObject.valueProperty.value = Utils.roundSymmetric( this.physicalRange.constrainValue( dragPosition.x ) );

this.moveToTop( casObject );
};
Expand Down
2 changes: 1 addition & 1 deletion js/common/model/SoccerModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ class SoccerModel extends CASModel {

const weights = this.currentDistribution;

assert && assert( weights.length === this.range.getLength() + 1, 'weight array should match the model range' );
assert && assert( weights.length === this.physicalRange.getLength() + 1, 'weight array should match the model range' );
const x1 = dotRandom.sampleProbabilities( weights ) + 1;

// Range equation is R=v0^2 sin(2 theta0) / g, see https://openstax.org/books/university-physics-volume-1/pages/4-3-projectile-motion
Expand Down
4 changes: 2 additions & 2 deletions js/common/view/CASScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,13 @@ class CASScreenView extends ScreenView {
model.objectChangedEmitter.addListener( updateMedianNode );
model.isShowingPlayAreaMedianProperty.link( updateMedianNode );

this.medianPredictionNode = new PredictionNode( model.medianPredictionProperty, this.modelViewTransform, model.range, {
this.medianPredictionNode = new PredictionNode( model.medianPredictionProperty, this.modelViewTransform, model.physicalRange, {
center: this.layoutBounds.center,
tandem: options.tandem.createTandem( 'medianPredictionNode' ),
color: CASColors.medianColorProperty,
roundToInterval: 0.5
} );
this.meanPredictionNode = new PredictionNode( model.meanPredictionProperty, this.modelViewTransform, model.range, {
this.meanPredictionNode = new PredictionNode( model.meanPredictionProperty, this.modelViewTransform, model.physicalRange, {
center: this.layoutBounds.center,
tandem: options.tandem.createTandem( 'meanPredictionNode' ),
color: CASColors.meanColorProperty,
Expand Down
4 changes: 2 additions & 2 deletions js/common/view/DotPlotNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ class DotPlotNode extends Node {
// 15 balls as the high point. Consider instead something like above, where we just base the y scaling on the height
// of one ball.
const modelViewTransform = ModelViewTransform2.createRectangleInvertedYMapping(
new Bounds2( model.range.min, 0, model.range.max, model.range.getLength() ),
new Bounds2( model.physicalRange.min, 0, model.physicalRange.max, model.physicalRange.getLength() ),
new Bounds2( 0, numberLinePositionY - numberLineWidth * yScale, 0 + numberLineWidth, numberLinePositionY )
);

const numberLineNode = new NumberLineNode(
model.range,
model.physicalRange,
numberLineWidth,
model.meanValueProperty,
model.isShowingTopMeanProperty,
Expand Down
4 changes: 2 additions & 2 deletions js/common/view/SoccerScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SoccerScreenView extends CASScreenView {

// The ground is at y=0
const modelViewTransform = ModelViewTransform2.createRectangleInvertedYMapping(
new Bounds2( model.range.min, 0, model.range.max, model.range.getLength() ),
new Bounds2( model.physicalRange.min, 0, model.physicalRange.max, model.physicalRange.getLength() ),
new Bounds2( NUMBER_LINE_MARGIN_X, GROUND_POSITION_Y - chartViewWidth, NUMBER_LINE_MARGIN_X + chartViewWidth, GROUND_POSITION_Y )
);

Expand All @@ -59,7 +59,7 @@ class SoccerScreenView extends CASScreenView {
this.contentLayer.addChild( new BackgroundNode( GROUND_POSITION_Y, this.visibleBoundsProperty ) );

this.playAreaNumberLineNode = new NumberLineNode(
model.range,
model.physicalRange,
chartViewWidth,
model.meanValueProperty,
model.isShowingPlayAreaMeanProperty,
Expand Down

0 comments on commit 4014603

Please sign in to comment.