Skip to content

Commit

Permalink
rename param to collides(), #68
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelzoom committed Sep 26, 2024
1 parent c82aa90 commit 239e665
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions js/common/model/BohrModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ export default class BohrModel extends HydrogenAtom {
protected collides( photon: Photon ): boolean {
const electronPosition = this.electron.positionProperty.value;
const photonPosition = photon.positionProperty.value;
const collisionCloseness = photon.radius + this.electron.radius;
return this.pointsCollide( electronPosition, photonPosition, collisionCloseness );
const maxDistance = photon.radius + this.electron.radius;
return this.pointsCollide( electronPosition, photonPosition, maxDistance );
}

//--------------------------------------------------------------------------------------------------------------------
Expand Down
5 changes: 2 additions & 3 deletions js/common/model/HydrogenAtom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ export default abstract class HydrogenAtom extends PhetioObject {

/**
* Determines if two points collide.
* Any distance between the points that is <= threshold is considered a collision.
*/
protected pointsCollide( position1: Vector2, position2: Vector2, threshold: number ): boolean {
return position1.distance( position2 ) <= threshold;
protected pointsCollide( position1: Vector2, position2: Vector2, maxDistance: number ): boolean {
return position1.distance( position2 ) <= maxDistance;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions js/common/model/PlumPuddingModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ export default class PlumPuddingModel extends HydrogenAtom {

const electronPosition = this.electron.positionProperty.value;
const photonPosition = photon.positionProperty.value;
const collisionCloseness = photon.radius + this.electron.radius;
const maxDistance = photon.radius + this.electron.radius;

if ( this.pointsCollide( electronPosition, photonPosition, collisionCloseness ) ) {
if ( this.pointsCollide( electronPosition, photonPosition, maxDistance ) ) {
if ( dotRandom.nextDouble() < PHOTON_ABSORPTION_PROBABILITY ) {
this.numberOfPhotonsAbsorbedProperty.value += 1;
assert && assert( this.numberOfPhotonsAbsorbedProperty.value <= MAX_PHOTONS_ABSORBED );
Expand Down

0 comments on commit 239e665

Please sign in to comment.