diff --git a/js/curve-fitting/CurveFittingConstants.js b/js/curve-fitting/CurveFittingConstants.js index c6cd188..a97961e 100644 --- a/js/curve-fitting/CurveFittingConstants.js +++ b/js/curve-fitting/CurveFittingConstants.js @@ -10,6 +10,8 @@ define( function() { 'use strict'; return { + MAX_ORDER_OF_FIT: 3, + // barometer BAROMETER_HEIGHT: 270, BAROMETER_TICK_WIDTH: 15, diff --git a/js/curve-fitting/model/Curve.js b/js/curve-fitting/model/Curve.js index 3ac9d59..fa0543f 100644 --- a/js/curve-fitting/model/Curve.js +++ b/js/curve-fitting/model/Curve.js @@ -24,10 +24,9 @@ define( function( require ) { /** * @param {Property.} orderOfFitProperty - Property to control curve type. * @param {Property.} fitTypeProperty - Property to control fit type. - * @param {number} maxFitOrder - Max order of fit. * @constructor */ - function Curve( orderOfFitProperty, fitTypeProperty, maxFitOrder ) { + function Curve( orderOfFitProperty, fitTypeProperty ) { var self = this; PropertySet.call( this, { @@ -53,7 +52,7 @@ define( function( require ) { this.points = new ObservableArray(); // special object to getting fit for points - this.fitMaker = new FitMaker( maxFitOrder ); + this.fitMaker = new FitMaker(); this._updateFitBound = this.updateFit.bind( this ); diff --git a/js/curve-fitting/model/CurveFittingModel.js b/js/curve-fitting/model/CurveFittingModel.js index 43fa25b..bc361ea 100644 --- a/js/curve-fitting/model/CurveFittingModel.js +++ b/js/curve-fitting/model/CurveFittingModel.js @@ -32,9 +32,6 @@ define( function( require ) { isEquationPanelExpanded: true // property to control equation panel expansion } ); - // max order of fit - this.maxOrderOfFit = 3; - // bucket model var BUCKET_WIDTH = 90; var BUCKET_HEIGHT = BUCKET_WIDTH * 0.50; @@ -46,7 +43,7 @@ define( function( require ) { } ); // curve model - this.curve = new Curve( this.orderOfFitProperty, this.fitTypeProperty, this.maxOrderOfFit ); + this.curve = new Curve( this.orderOfFitProperty, this.fitTypeProperty ); // graph area size this.graphArea = { diff --git a/js/curve-fitting/model/FitMaker.js b/js/curve-fitting/model/FitMaker.js index ddc510f..4837d73 100644 --- a/js/curve-fitting/model/FitMaker.js +++ b/js/curve-fitting/model/FitMaker.js @@ -5,16 +5,18 @@ * * @author Andrey Zelenkov (Mlearner) */ -define( function() { +define( function( require ) { 'use strict'; + // modules + var CurveFittingConstants = require( 'CURVE_FITTING/curve-fitting/CurveFittingConstants' ); + /** - * @param {number} maxOrderOfFit - Max order of fit. * @constructor */ - function FitMaker( maxOrderOfFit ) { + function FitMaker() { // set max size of matrix - this.maxM = maxOrderOfFit + 1; + this.maxM = CurveFittingConstants.MAX_ORDER_OF_FIT + 1; this.m = null; // create solution array diff --git a/js/curve-fitting/view/ControlMenuNode.js b/js/curve-fitting/view/ControlMenuNode.js index 104e536..df668a0 100644 --- a/js/curve-fitting/view/ControlMenuNode.js +++ b/js/curve-fitting/view/ControlMenuNode.js @@ -83,7 +83,7 @@ define( function( require ) { this.addChild( curveTypePanel ); // create fit type menu - var fitTypeMenu = new FitTypeMenu( curveFittingModel.curve, curveFittingModel.fitTypeProperty, curveFittingModel.orderOfFitProperty, curveFittingModel.maxOrderOfFit ); + var fitTypeMenu = new FitTypeMenu( curveFittingModel.curve, curveFittingModel.fitTypeProperty, curveFittingModel.orderOfFitProperty, curveFittingModel ); this.addChild( fitTypeMenu ); // add observers diff --git a/js/curve-fitting/view/EquationFitNode.js b/js/curve-fitting/view/EquationFitNode.js index 8213ca5..16cbe9a 100644 --- a/js/curve-fitting/view/EquationFitNode.js +++ b/js/curve-fitting/view/EquationFitNode.js @@ -30,16 +30,15 @@ define( function( require ) { /** * @param {Property.} orderFitProperty parameter to track. - * @param {number} maxOrderFit - Possible range for property. * @param {Object} [options] for slider node. * @constructor */ - function EquationFitNode( orderFitProperty, maxOrderFit, options ) { + function EquationFitNode( orderFitProperty, options ) { var self = this; var equationTextArray = []; var boxNode; - for ( var i = 1; i < maxOrderFit + 1; i++ ) { + for ( var i = 1; i < CurveFittingConstants.MAX_ORDER_OF_FIT + 1; i++ ) { boxNode = new HBox( { align: 'bottom' } ); var yNode = new Text( 'y = ', TEXT_OPTIONS ); boxNode.addChild( yNode ); diff --git a/js/curve-fitting/view/FitTypeMenu.js b/js/curve-fitting/view/FitTypeMenu.js index 988622a..2776fc8 100644 --- a/js/curve-fitting/view/FitTypeMenu.js +++ b/js/curve-fitting/view/FitTypeMenu.js @@ -37,11 +37,10 @@ define( function( require ) { * @param {Curve} curve model. * @param {Property.} fitTypeProperty - Property to control fit type of curve. * @param {Property.} orderOfFitProperty - Property to control type of curve. - * @param {number} maxOrderOfFit - Max order of fit. * @param {Object} [options] for graph node. * @constructor */ - function FitTypeMenu( curve, fitTypeProperty, orderOfFitProperty, maxOrderOfFit, options ) { + function FitTypeMenu( curve, fitTypeProperty, orderOfFitProperty, options ) { var content = new VBox(); // create radio buttons @@ -53,7 +52,7 @@ define( function( require ) { content.addChild( fitTypeRadioButtonGroup ); // create equation node - content.addChild( new EquationFitNode( orderOfFitProperty, maxOrderOfFit ) ); + content.addChild( new EquationFitNode( orderOfFitProperty ) ); // create slider for parameters var aSliderBox = new SliderParameterNode( curve.aProperty, { min: -1, max: 1 }, 'a' );