Skip to content

Commit

Permalink
just pass in positionProperty, #149
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Aug 21, 2023
1 parent 7d9cfbb commit b24efea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion js/chart-intro/view/ChartIntroScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class ChartIntroScreenView extends BANScreenView<ChartIntroModel> {
* Returns whether the nucleon is within a rectangular capture radius defined by the left edge of the proton arrow
* buttons, the right edge of the neutron arrow buttons, below the periodic table, and above the arrow buttons.
*/
protected override isNucleonInCaptureArea( nucleon: Particle, atom: ParticleAtom ): boolean {
protected override isNucleonInCaptureArea( nucleon: Particle ): boolean {
const nucleonViewPosition = this.particleTransform.modelToViewPosition( nucleon.positionProperty.value );

return this.protonEnergyLevelNode.boundsProperty.value.dilated( BANConstants.PARTICLE_DIAMETER ).containsPoint( nucleonViewPosition ) ||
Expand Down
4 changes: 2 additions & 2 deletions js/common/view/BANScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ abstract class BANScreenView<M extends BANModel<ParticleAtom | ParticleNucleus>>
const particleCreatorNodeCenter = nucleon.type === ParticleType.PROTON.particleTypeString ?
this.protonsCreatorNode.center : this.neutronsCreatorNode.center;

if ( this.isNucleonInCaptureArea( nucleon, atom ) ||
if ( this.isNucleonInCaptureArea( nucleon, atom.positionProperty ) ||

// if removing the nucleon will create a nuclide that does not exist, re-add the nucleon to the atom
( ( this.model.particleAtom.protonCountProperty.value + this.model.particleAtom.neutronCountProperty.value ) !== 0 &&
Expand All @@ -806,7 +806,7 @@ abstract class BANScreenView<M extends BANModel<ParticleAtom | ParticleNucleus>>
* Returns if a nucleon is in the capture area which is in a certain radius around the atom in the Decay Screen, and
* the energy level area in the Chart Screen.
*/
protected abstract isNucleonInCaptureArea( nucleon: Particle, atom: ParticleAtom ): boolean;
protected abstract isNucleonInCaptureArea( nucleon: Particle, atomPositionProperty: TReadOnlyProperty<Vector2> ): boolean;

/**
* Add particleView to correct layer.
Expand Down
5 changes: 3 additions & 2 deletions js/decay/view/DecayScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import AlphaParticle from '../../common/model/AlphaParticle.js';
import ReturnButton from '../../../../scenery-phet/js/buttons/ReturnButton.js';
import BANQueryParameters from '../../common/BANQueryParameters.js';
import ShowElectronCloudCheckbox from './ShowElectronCloudCheckbox.js';
import TReadOnlyProperty from '../../../../axon/js/TReadOnlyProperty.js';

// constants
const NUCLEON_CAPTURE_RADIUS = 100;
Expand Down Expand Up @@ -310,8 +311,8 @@ class DecayScreenView extends BANScreenView<DecayModel> {
/**
* Returns whether the nucleon is within the circular capture radius around the atom.
*/
protected override isNucleonInCaptureArea( nucleon: Particle, atom: ParticleAtom ): boolean {
return nucleon.positionProperty.value.distance( atom.positionProperty.value ) < NUCLEON_CAPTURE_RADIUS;
protected override isNucleonInCaptureArea( nucleon: Particle, atomPositionProperty: TReadOnlyProperty<Vector2> ): boolean {
return nucleon.positionProperty.value.distance( atomPositionProperty.value ) < NUCLEON_CAPTURE_RADIUS;
}

protected override reset(): void {
Expand Down

0 comments on commit b24efea

Please sign in to comment.