Skip to content

Commit

Permalink
Set interceptOffset to 0, #92
Browse files Browse the repository at this point in the history
  • Loading branch information
samreid committed Dec 20, 2024
1 parent 0ef7b62 commit 9200659
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions js/least-squares-regression/model/Graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class Graph {
// Factors for slope and intercept conversions
public slopeFactor!: number;
public interceptFactor!: number;
public interceptOffset!: number;
public readonly interceptOffset = 0;

// Statistical fields
private averageOfSumOfSquaresXX!: number;
Expand Down Expand Up @@ -128,7 +128,6 @@ export default class Graph {
public setGraphDomain( xRange: Range, yRange: Range ): void {
this.slopeFactor = ( yRange.max - yRange.min ) / ( xRange.max - xRange.min ) / ( this.bounds.height / this.bounds.width );
this.interceptFactor = ( yRange.max - yRange.min ) / this.bounds.height;
this.interceptOffset = ( yRange.min );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ export default class LeastSquaresRegressionModel {
this.graph.setGraphDomain( selectedDataSet.xRange, selectedDataSet.yRange );

// Populate the dataPoints array

if ( selectedDataSet === DataSet.CUSTOM ) {

// use the savedCustomDataPoints to populate the dataPoints array
Expand Down
3 changes: 1 addition & 2 deletions js/least-squares-regression/view/GraphNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export default class GraphNode extends Node {
const myLineBoundaryPoints = graph.getBoundaryPoints( graph.slope( graph.angleProperty.value ), graph.interceptProperty.value );
this.myLine = new Line(
modelViewTransform.modelToViewPosition( myLineBoundaryPoints.point1 ),
modelViewTransform.modelToViewPosition( myLineBoundaryPoints.point2 ),
{
modelViewTransform.modelToViewPosition( myLineBoundaryPoints.point2 ), {
stroke: LeastSquaresRegressionConstants.MY_LINE_COLOR.BASE_COLOR,
lineWidth: LeastSquaresRegressionConstants.LINE_WIDTH
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class LeastSquaresRegressionScreenView extends ScreenView {
resize: false
}, panelOptions ) );

// Create the "My Line" Control Panel (located to the left of the graph)
// Create the "My Line" Control Panel (located to the right of the graph)
const myLineControlPanel = new MyLineControlPanel( model.graph, model.dataPointsAddedEmitter, panelOptions );

// Create the Graph Node which is responsible for 'My Line', 'Best Fit Line' and the Residuals representation
Expand Down

0 comments on commit 9200659

Please sign in to comment.