Skip to content

Commit

Permalink
only turn on precession when measurement is in progress, see #80
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Jan 15, 2025
1 parent 33c5ab2 commit 3dfc9f3
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions js/bloch-sphere/model/BlochSphereModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,21 +201,18 @@ class BlochSphereModel implements TModel {
// Set the precession rate of the Bloch sphere based on the state of the magnetic field, the selected scene, and the
// measurement state.
Multilink.lazyMultilink(
[ this.magneticFieldStrengthProperty, this.magneticFieldEnabledProperty ],
( magneticFieldStrength, showMagneticField ) => {
[ this.magneticFieldStrengthProperty, this.magneticFieldEnabledProperty, this.measurementStateProperty ],
( magneticFieldStrength, showMagneticField, measurementState ) => {

// Changes to the field state should clear any accumulated counts.
this.resetCounts();

// Set the precession rate of the Bloch sphere based on the state of the magnetic field.

this.singleMeasurementBlochSphere.rotatingSpeedProperty.value = showMagneticField ?
magneticFieldStrength :
0;
// Set the precession rate of the Bloch sphere based on the measurement state and the state of the magnetic
// field.
const rotationRate = measurementState === 'timingObservation' && showMagneticField ? magneticFieldStrength : 0;
this.singleMeasurementBlochSphere.rotatingSpeedProperty.value = rotationRate;
this.multiMeasurementBlochSpheres.forEach( blochSphere => {
blochSphere.rotatingSpeedProperty.value = showMagneticField ?
magneticFieldStrength :
0;
blochSphere.rotatingSpeedProperty.value = rotationRate;
} );
}
);
Expand Down

0 comments on commit 3dfc9f3

Please sign in to comment.