Skip to content

Commit

Permalink
only precess when in "Precession" mode, see #54
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Jan 4, 2025
1 parent 08d8c5d commit 81e48ae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 8 additions & 3 deletions js/bloch-sphere/model/BlochSphereModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,14 @@ export default class BlochSphereModel implements TModel {
}
);

this.magneticFieldStrengthProperty.link( magneticFieldStrength => {
this.singleMeasurementBlochSphere.rotatingSpeedProperty.value = magneticFieldStrength;
} );
Multilink.multilink(
[ this.magneticFieldStrengthProperty, this.selectedSceneProperty ],
( magneticFieldStrength, selectedScene ) => {
this.singleMeasurementBlochSphere.rotatingSpeedProperty.value = selectedScene === BlochSphereScene.PRECESSION ?
magneticFieldStrength :
0;
}
);

this.preparationBlochSphere.polarAngleProperty.link( polarAngle => {
this.singleMeasurementBlochSphere.polarAngleProperty.value = polarAngle;
Expand Down
4 changes: 3 additions & 1 deletion js/bloch-sphere/model/ComplexBlochSphere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export default class ComplexBlochSphere extends AbstractBlochSphere {
* Abstract method that should run calculations to update the Bloch Sphere representation.
*/
public override step( dt: number ): void {
this.azimuthalAngleProperty.value = Utils.moduloBetweenDown( this.azimuthalAngleProperty.value + this.rotatingSpeedProperty.value * dt, 0, 2 * Math.PI );
this.azimuthalAngleProperty.value = Utils.moduloBetweenDown(
this.azimuthalAngleProperty.value + this.rotatingSpeedProperty.value * dt, 0, 2 * Math.PI
);
}

public override reset(): void {
Expand Down

0 comments on commit 81e48ae

Please sign in to comment.