Skip to content

Commit

Permalink
add control for photon polarization angle, see #52
Browse files Browse the repository at this point in the history
  • Loading branch information
jbphet committed Oct 11, 2024
1 parent 7254aed commit 5caf14c
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 16 deletions.
4 changes: 2 additions & 2 deletions js/bloch-sphere/view/BlochSphereScreenView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ export default class BlochSphereScreenView extends QuantumMeasurementScreenView
azimuthSlider
]
} ), {
fill: QuantumMeasurementColors.basisStatesPanelFillColorProperty,
stroke: QuantumMeasurementColors.basisStatesPanelStrokeColorProperty,
fill: QuantumMeasurementColors.controlPanelFillColorProperty,
stroke: QuantumMeasurementColors.controlPanelStrokeColorProperty,
yMargin: 10,
minWidth: 270
} );
Expand Down
4 changes: 2 additions & 2 deletions js/coins/view/InitialCoinStateSelectorNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export default class InitialCoinStateSelectorNode extends VBox {
} );

const selectorPanel = new Panel( selectorPanelContent, {
fill: QuantumMeasurementColors.basisStatesPanelFillColorProperty,
stroke: QuantumMeasurementColors.basisStatesPanelStrokeColorProperty,
fill: QuantumMeasurementColors.controlPanelFillColorProperty,
stroke: QuantumMeasurementColors.controlPanelStrokeColorProperty,
yMargin: 10,
minWidth: 270,
visibleProperty: new GatedVisibleProperty( preparingExperimentProperty, radioButtonGroupTandem ),
Expand Down
16 changes: 12 additions & 4 deletions js/common/QuantumMeasurementColors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ const QuantumMeasurementColors = {
default: '#0ffdfd'
} ),

// Initial Orientation/Basis States panel stroke
basisStatesPanelStrokeColorProperty: new ProfileColorProperty( quantumMeasurement, 'basisStatesPanelStroke', {
// control panel stroke
controlPanelStrokeColorProperty: new ProfileColorProperty( quantumMeasurement, 'basisStatesPanelStroke', {
default: 'transparent'
} ),

// Initial Orientation/Basis States panel fill
basisStatesPanelFillColorProperty: new ProfileColorProperty( quantumMeasurement, 'basisStatesPanelFill', {
// control panel fill
controlPanelFillColorProperty: new ProfileColorProperty( quantumMeasurement, 'basisStatesPanelFill', {
default: '#EEE'
} ),

Expand All @@ -125,6 +125,14 @@ const QuantumMeasurementColors = {
} ),
landingZoneFillColorProperty: new ProfileColorProperty( quantumMeasurement, 'landingZoneFill', {
default: 'rgba( 255, 192, 203, 0.5 )'
} ),

// Colors for the photon polarization
horizontalPolarizationColorProperty: new ProfileColorProperty( quantumMeasurement, 'horizontalPolarization', {
default: '#F0F'
} ),
verticalPolarizationColorProperty: new ProfileColorProperty( quantumMeasurement, 'verticalPolarization', {
default: '#00F'
} )
};

Expand Down
9 changes: 9 additions & 0 deletions js/photons/model/PolarizingBeamSplitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ export default class PolarizingBeamSplitter {
this.customPolarizationAngleProperty = new NumberProperty( 45, {
tandem: providedOptions.tandem.createTandem( 'customPolarizationAngleProperty' )
} );

// TODO: This is temporary code to log changes to the properties. It will be removed later. See https://github.com/phetsims/quantum-measurement/issues/52.
this.presetPolarizationDirectionProperty.lazyLink( presetPolarizationDirection => {
console.log( `presetPolarizationDirection = ${presetPolarizationDirection}` );
} );
this.customPolarizationAngleProperty.lazyLink( customPolarizationAngleProperty => {
console.log( `customPolarizationAngleProperty = ${customPolarizationAngleProperty}` );
} );

}
}

Expand Down
18 changes: 12 additions & 6 deletions js/photons/view/PhotonsExperimentSceneView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import WithRequired from '../../../../phet-core/js/types/WithRequired.js';
import { Color, HBox, HBoxOptions, Rectangle } from '../../../../scenery/js/imports.js';
import quantumMeasurement from '../../quantumMeasurement.js';
import PhotonsExperimentSceneModel from '../model/PhotonsExperimentSceneModel.js';
import PhotonPolarizationAngleControl from './PhotonPolarizationAngleControl.js';

type SelfOptions = EmptySelfOptions;
type PhotonsExperimentSceneViewOptions = SelfOptions & WithRequired<HBoxOptions, 'tandem'>;
Expand All @@ -21,10 +22,6 @@ export default class PhotonsExperimentSceneView extends HBox {

// TODO: This set of rectangles is a placeholder for working on layout, see https://github.com/phetsims/quantum-measurement/issues/52
const testRectHeight = 510;
const testRect1 = new Rectangle( 0, 0, 220, testRectHeight, {
fill: new Color( '#C35985' ),
stroke: new Color( '#C35985' ).darkerColor( 0.5 )
} );
const testRect2 = new Rectangle( 0, 0, 370, testRectHeight, {
fill: new Color( '#947A0C' ),
stroke: new Color( '#947A0C' ).darkerColor( 0.5 ),
Expand All @@ -41,9 +38,18 @@ export default class PhotonsExperimentSceneView extends HBox {
lineWidth: 2
} );

const photonPolarizationAngleControl = new PhotonPolarizationAngleControl(
model.polarizingBeamSplitter.presetPolarizationDirectionProperty,
model.polarizingBeamSplitter.customPolarizationAngleProperty,
{
tandem: providedOptions.tandem.createTandem( 'photonPolarizationAngleControl' )
}
);

const options = optionize<PhotonsExperimentSceneViewOptions, SelfOptions, HBoxOptions>()( {
children: [ testRect1, testRect2, testRect3, testRect4 ],
spacing: 3
children: [ photonPolarizationAngleControl, testRect2, testRect3, testRect4 ],
spacing: 3,
align: 'bottom'
}, providedOptions );

super( options );
Expand Down
2 changes: 1 addition & 1 deletion js/spin/view/SpinStatePreparationArea.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class SpinStatePreparationArea extends VBox {
center: new Vector2( 100, 100 ),
tandem: tandem.createTandem( 'numberOfCoinsRadioButtonGroup' ),
radioButtonOptions: {
baseColor: QuantumMeasurementColors.basisStatesPanelFillColorProperty
baseColor: QuantumMeasurementColors.controlPanelFillColorProperty
}
}
);
Expand Down
2 changes: 1 addition & 1 deletion quantum-measurement-strings_en.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"value": "Coin Bias (State)"
},
"custom": {
"value": "custom"
"value": "Custom"
},
"down": {
"value": "Down"
Expand Down

0 comments on commit 5caf14c

Please sign in to comment.