Skip to content

Commit

Permalink
replace Math.trunc with Math.floor, #126
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Mar 26, 2024
1 parent e66b746 commit 9d427ac
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions js/common/model/BarMagnetFieldGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ export default class BarMagnetFieldGrid {
if ( this.contains( x, y ) ) {

// compute array indices
let columnIndex = Math.trunc( x / this.spacing );
let rowIndex = Math.trunc( y / this.spacing );
let columnIndex = Math.floor( x / this.spacing );
let rowIndex = Math.floor( y / this.spacing );

// If we're at one of the index maximums, then we're exactly on the outer edge of the grid.
// Back up by 1 so that we'll have a bounding rectangle.
Expand Down
2 changes: 1 addition & 1 deletion js/common/model/Coil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export default class Coil extends PhetioObject {
numberOfElectrons = ELECTRONS_IN_RIGHT_END;
}
else {
numberOfElectrons = Math.trunc( this.loopRadiusProperty.value / ELECTRON_SPACING );
numberOfElectrons = Math.floor( this.loopRadiusProperty.value / ELECTRON_SPACING );
}
assert && assert( Number.isInteger( numberOfElectrons ) && numberOfElectrons > 0,
`invalid numberOfElectrons: ${numberOfElectrons}` );
Expand Down
2 changes: 1 addition & 1 deletion js/common/model/PickupCoilSamplePointsStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class FixedSpacingSamplePointsStrategy extends PickupCoilSamplePointsStra
}

protected override createSamplePointsProtected( loopRadius: number ): Vector2[] {
const numberOfSamplePointsOnRadius = Math.trunc( loopRadius / this.ySpacing );
const numberOfSamplePointsOnRadius = Math.floor( loopRadius / this.ySpacing );
return createSamplePoints( numberOfSamplePointsOnRadius, this.ySpacing );
}
}
Expand Down

0 comments on commit 9d427ac

Please sign in to comment.